Menu

Help! Unicode and WinMain@16 problem, aga

Neo
2005-03-12
2012-09-26
  • Neo

    Neo - 2005-03-12

    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.

     
    • Neo

      Neo - 2005-03-14

      Thanks. I think I have to stick to non-Unicode build.

       
    • Neo

      Neo - 2005-03-13

      No reply??? Can anyone help?

       
    • Liviu Nicolescu

      Liviu Nicolescu - 2005-03-13

      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

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.