使用vs2005 + STLport-5.2.1, 编译时出现LNK2019错.
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall stlp_std::basic_string<unsigned short,class stlp_std::char_traits<unsigned short>,class stlp_std::allocator<unsigned short> >::~basic_string<unsigned short,class stlp_std::char_traits<unsigned short>,class stlp_std::allocator<unsigned short> >(void)" (__imp_??1?$basic_string@GV?$char_traits@G@stlp_std@@V?$allocator@G@2@@stlp_std@@QAE@XZ) referenced in function _wmain srcVoteState.obj
用屏蔽法定位到
std::wstring strRc;
想起在编译选项时,改过选项 wchar_t build in, 使wchar不为内建类型(/Zc:wchar_t-).
回想StlPort编译过程, 当时选择的是默认选项编译, 没有选择 /G7 选项. 将vs2005工程的wchar_t build in 改回yes编译通过.
stlPort 编译时使用 wchar_t build in 选项如下:
echo. echo "--extra-cxxflag <additional compilation options>" echo Use this option to add any compilation flag to the build system. For instance echo it can be used to activate a specific processor optimization depending on your echo processor. For Visual C++ .Net 2003, to activate pentium 3 optim you will use: echo --extra-cxxflag /G7 echo If you have several options use several --extra-cxxflag options. For instance echo to also force use of wchar_t as an intrinsic type: echo --extra-cxxflag /G7 --extra-cxxflag /Zc:wchar_t
如果加载的第三方库多了, 出现LNK2019, 就需要将所有Lib的wchar_t build in 选项统一. 比如codeproject上的一些demo, 如果不选(/Zc:wchar_t-), 就编译不过.
<2011_1026>
今天,同事遇到vs2003ide中贴入vs2005工程中拷贝进来的代码, 编译不过提示是 "不可是别的0xA6", 用另存编码的方法没解决问题。后来他查到是贴进来的代码中用到的宏编码不正确,但是这个宏在另外一个文件中粘贴进来的. 后来他手工键入了那个宏,搞定. 看来修改要一小步一小步的来, 要不这种奇怪得问题,不好排查。