Unicode in MinGW

This is a discussion on Unicode in MinGW within the C++ Programming forums, part of the General Programming Boards category; Wanting to support Unicode in my applications. Two questions. How can I use something like a _tmain/wmain when compiling with ...

  1. #1
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465

    Unicode in MinGW

    Wanting to support Unicode in my applications. Two questions.

    How can I use something like a _tmain/wmain when compiling with g++? Do I have to specifiy the entry point for it myself? How would I do that with _tmain? Detect a UNICODE flag in the makefile and conditionally do it?

    Error with STLPort. I do

    cd /build/lib, make -f gcc.mak clean install, No errors.
    cd ../test/util, make -f gcc.mak clean install, Errors?!

    All sorts of undefined references.

    stlp_std::char_traits<char>, stlp_std::allocator<char> >(stlp_std::basic_ostrea
    m<char, stlp_std::char_traits<char> >&, stlp_std::basic_string<char, stlp_std::c
    har_traits<char>, stlp_std::allocator<char> > const&)]+0x209):string_test.cpp: u
    ndefined reference to `_imp___ZN8stlp_std8ios_base16_M_throw_failureEv'
    obj/gcc/shared/string_test.o(.text$_ZN8stlp_stdlsIcNS_11char_trai tsIcEENS_9alloc
    atorIcEEEERNS_13basic_ostreamIT_T0_EES9_RKNS_12bas ic_stringIS6_S7_T1_EE[stlp_std
    ::basic_ostream<char, stlp_std::char_traits<char> >& stlp_std::operator<< <char,
    stlp_std::char_traits<char>, stlp_std::allocator<char> >(stlp_std::basic_ostrea
    m<char, stlp_std::char_traits<char> >&, stlp_std::basic_string<char, stlp_std::c
    har_traits<char>, stlp_std::allocator<char> > const&)]+0x289):string_test.cpp: u
    ndefined reference to `_imp___ZN8stlp_std8ios_base16_M_throw_failureEv'
    obj/gcc/shared/string_test.o(.text$_ZN8stlp_stdlsIcNS_11char_trai tsIcEENS_9alloc
    atorIcEEEERNS_13basic_ostreamIT_T0_EES9_RKNS_12bas ic_stringIS6_S7_T1_EE[stlp_std
    ::basic_ostream<char, stlp_std::char_traits<char> >& stlp_std::operator<< <char,
    stlp_std::char_traits<char>, stlp_std::allocator<char> >(stlp_std::basic_ostrea
    m<char, stlp_std::char_traits<char> >&, stlp_std::basic_string<char, stlp_std::c
    har_traits<char>, stlp_std::allocator<char> > const&)]+0x3ab):string_test.cpp: u
    ndefined reference to `_imp___ZN8stlp_std8ios_base16_M_throw_failureEv'
    obj/gcc/shared/vector_test.o(.text$_ZNK8stlp_std12_Vector_baseIiN S_9allocatorIiE
    EE21_M_throw_length_errorEv[stlp_std::_Vector_base<int, stlp_std::allocator<int>
    >::_M_throw_length_error() const]+0xc):vector_test.cpp: undefined reference to
    `_imp___ZN8stlp_std24__stl_throw_length_errorEPKc'
    obj/gcc/shared/vector_test.o(.text$_ZNK8stlp_std12_Vector_baseIiN S_9allocatorIiE
    EE21_M_throw_out_of_rangeEv[stlp_std::_Vector_base<int, stlp_std::allocator<int>
    >::_M_throw_out_of_range() const]+0xc):vector_test.cpp: undefined reference to
    `_imp___ZN8stlp_std24__stl_throw_out_of_rangeEPKc'
    collect2: ld returned 1 exit status
    make: *** [obj/gcc/shared/stl_unit_test.exe] Error 1
    Using cout object results in more errors.

    Code:
    std::cout << "Test" << "std::endl";
    Results

    main.o(.text+0x35): In function `ZNK11stlpmtx_std9basic_iosIcNS_11char_traitsIcE
    EE3tieEv':
    C:/mingw/stlport/stl/_ios.h:62: undefined reference to `stlpmtx_std::cout'
    main.o(.text$_ZN11stlpmtx_std8ios_base23_M_check_e xception_maskEv[stlpmtx_std::i
    os_base::_M_check_exception_mask()]+0x1d):C:/mingw/stlport/stl/_ios.h:62: undefi
    ned reference to `stlpmtx_std::ios_base::_M_throw_failure()'
    collect2: ld returned 1 exit status
    Last edited by Tonto; 08-31-2006 at 10:59 PM.

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    It looks to me like you haven't provided the paths to stlport's include and lib directories.

    If you want to use wide characters, eg std::wstring, then you should use wide character streams, too, ie use std::wcout and not std::cout.

    I should warn you, although it may not be relevant in the context of your current questions, that for windows there is no wWinMain with MinGW unless you build it for yourself. This isn't a big issue as you can still use WinMain and GetCommandLine; the latter will return a wide character string of command line arguments as required.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    1) How do I do that? The results of that are those of the unit test, where I say make -f gcc.mak install in the /build/test/unit dir.

    2) I know. It fails using any iostream functions. Seems to have not been configured correctly?

    3) Yup, thanks. Does the same apply to like, _tmain?

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    1. check the makefile(s)/docs for instructions. It may just be something simple like a missing flag like -mthreads.

    2. Can you build a simple 'hello world' example?

    3. I think so, yes.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    1) I read the install file, and am now following instructions for testing the build. It's a long process that takes like 5 minutes, and I can see that -mthreads is already specified in what it is compiling.

    2) Nope. Here's the errors.

    Code:
    g++ -c -Wall -g -mthreads -I "C:/mingw/stlport" main.cpp -o main.o
    g++ -lstlport.5.0.dll main.o -o main.exe
    main.o(.text+0x35): In function `ZNK8stlp_std9basic_iosIcNS_11char_traitsIcEEE3t
    ieEv':
    C:/mingw/stlport/stl/_ios.h:62: undefined reference to `stlp_std::cout'
    main.o(.text$_ZN8stlp_std8ios_base23_M_check_exception_maskEv[stlp_std::ios_base
    ::_M_check_exception_mask()]+0x1d):C:/mingw/stlport/stl/_ios.h:62: undefined ref
    erence to `stlp_std::ios_base::_M_throw_failure()'
    collect2: ld returned 1 exit status
    make: *** [main] Error 1

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unsupported Unicode ADDRINFO stuff
    By Tonto in forum C++ Programming
    Replies: 2
    Last Post: 01-23-2007, 07:22 AM
  2. <string> to LPCSTR? Also, character encoding: UNICODE vs ?
    By Kurisu33 in forum C++ Programming
    Replies: 7
    Last Post: 10-09-2006, 12:48 AM
  3. Unicode - a lot of confusion...
    By Jumper in forum Windows Programming
    Replies: 11
    Last Post: 07-05-2004, 07:59 AM
  4. Should I go to unicode?
    By nickname_changed in forum C++ Programming
    Replies: 10
    Last Post: 10-13-2003, 11:37 AM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21