My test program is very simple:
class test { public: test() { _putts(_T("Hello wonderful world!")); } };
int _tmain(int argc, TCHAR** argv) { test t;
_putts(_T("Press ENTER key to end...")); _gettchar();
return 0; }
If I compile with _UNICODE/UNICODE defined, I get the following error:
g++.exe -c test.cpp -o test.o -I"C:/Dev-C++/include" -I"C:/MinGW/include/c++/3.4.2" -D_UNICODE -DUNICODE
g++.exe test.o -o "test.exe" -L"C:/Dev-C++/lib" -L"C:/MinGW/lib"
C:/MinGW/lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16' collect2: ld returned 1 exit status
mingw32-make: *** [test.exe] Error 1
If I don't define _UNICODE/UNICODE then the project builds successfully.
I searched the web for solutions, but none of them works for me.
Thanks. I think I have to stick to non-Unicode build.
No reply??? Can anyone help?
MingW does not provide a wide startup module as stated in tchar.h:
/ for porting from other Windows compilers /
You can use the standard entry point main( int argc, char** argv) and your sample compiles and runs without errors.
If you need the wide version of argv, you might use the CommandLineToArgvW function:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/commandlinetoargvw.asp
Liviu
Log in to post a comment.
My test program is very simple:
include <stdio.h>
include <tchar.h>
class test
{
public:
test()
{
_putts(_T("Hello wonderful world!"));
}
};
ifdef _UNICODE
define _gettchar getwchar
else
define _gettchar getchar
endif
int _tmain(int argc, TCHAR** argv)
{
test t;
_putts(_T("Press ENTER key to end..."));
_gettchar();
return 0;
}
If I compile with _UNICODE/UNICODE defined, I get the following error:
g++.exe -c test.cpp -o test.o -I"C:/Dev-C++/include" -I"C:/MinGW/include/c++/3.4.2" -D_UNICODE -DUNICODE
g++.exe test.o -o "test.exe" -L"C:/Dev-C++/lib" -L"C:/MinGW/lib"
C:/MinGW/lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
mingw32-make: *** [test.exe] Error 1
If I don't define _UNICODE/UNICODE then the project builds successfully.
I searched the web for solutions, but none of them works for me.
Thanks. I think I have to stick to non-Unicode build.
No reply??? Can anyone help?
MingW does not provide a wide startup module as stated in tchar.h:
/ for porting from other Windows compilers /
if 0 / no wide startup module /
define _tmain wmain
define _tWinMain wWinMain
define _tenviron _wenviron
define __targv __wargv
endif
You can use the standard entry point main( int argc, char** argv) and your sample compiles and runs without errors.
If you need the wide version of argv, you might use the CommandLineToArgvW function:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/commandlinetoargvw.asp
Liviu