How to use vcl components in console applications?

535 Views Asked by At

Although I have included header vcl.h, I get a linker error when trying to use TStringList objects in console application. My particular question is how to use TStringList and other vcl components in console applications. Here is my code snippet and the below is the linker error.

[ILINK32 Error] Error: Unresolved external 'Classes::TStringList::' referenced from XXX.OBJ

#pragma hdrstop

#include <tchar.h>
#include <vcl.h>
#include <iostream.h>
#include <conio.h>


#pragma argsused

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    TStringList* AList = new TStringList;
    delete AList;
    return 0;
}
1

There are 1 best solutions below

0
Remy Lebeau On

When you use the Console Wizard to create the project, make sure to enable the 'Use VCL" checkbox:

Creates an application that can contain VCL components. This option is available only if you choose C++ as your Source Type. Checking this option causes the IDE to include vcl.h and to change the startup code and linker options for compatibility with VCL objects.

screenshot