读书人

在winXP上g++编译wstring求高人指

发布时间: 2013-02-27 10:48:11 作者: rapoo

在winXP下,g++编译wstring,求高人指点
hello.cpp:

#define _GLIBCXX_USE_WCHAR_T 1
#define _GLIBCXX_USE_WSTRING 1
#include <string>
#include <iostream>

using namespace std;

int main()
{
wstring s11 = L"hello world!";
return 0 ;
}

=======================================
$ g++ -o hello.exe hello.cpp

=======================================
/tmp/ccqYCfYU.o:hello.cpp:(.text+0x184): undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::basic_string(wchar_t const*, std::allocator<wchar_t> const&)'
/tmp/ccqYCfYU.o:hello.cpp:(.text+0x1d5): undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::~basic_string()'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: /tmp/ccqYCfYU.o: bad reloc address 0x0 in section `.ctors'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status


=======================================
求解,为什么 wstring 编译不过呢?
[解决办法]
我这边在Ubuntu下用GCC编译是没有问题的。
[解决办法]
Thread model: win32
gcc version 4.7.1 (tdm-1)
mingw32 没问题

读书人网 >C++

热点推荐