您的位置:首页 > 其它

vc6 和 vc8 同时编译stlport 5.1.4 引起的问题

2008-01-05 17:27 387 查看
系统安装了vc6和vs 2005两个编译器,使用vc6编译stlport5.1.4,没有任何问题,测试程序也正确。使用vc8 编译时,碰到一些问题。
进入stlport 5.1.4目录下的build/lib目录,执行
configure.bat -c msvc8
返回成功
执行
nmake /fmsvc.mak
出错
说无法解析build/Makefiles/nmake/vc8.mak里面的/Wp64,将其去掉后,
可以编译,但总出警告,说不认识/GL这个标识
但最终还是生成了相应的.lib和.dll,而且生成在build/lib/obj/vc8目录下,这给了我很大困惑。
不过在vs2005下测试时,编译没问题,链接时报告LNK2001和LNK2019错误
测试代码:
#include <string>
#include <iostream>

using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string a = "hello world";
cout<<a<<endl;
return 0;
}

vs2005
错误 3 error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >(class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &)" (__imp_??0?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@QAE@ABV01@@Z)

ERROR 3 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >(class stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &)" (__imp_??0?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@QAE@ABV01@@Z)

错误 1 error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::~basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >(void)" (__imp_??1?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@QAE@XZ),该符号在函数 _wmain 中被引用

ERROR 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::~basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >(void)" (__imp_??1?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@QAE@XZ),referenced in function _wmain teststlport.obj

在编译环境中增加lib的正确路径和对stlportd.5.1.lib 的引用,不起作用。而在vc6中则无此问题。
网上很少有人碰到这样的问题,所以基本搜不到任何资料。
怀疑是编译环境有问题。因为生成出来的lib和dll,与使用configure -c msvc6出来的byte数没有任何差别。但就是因为生成在vc8目录下,让我以为是正确的。
我打印path环境变量,发现path里的路径,都是vc6的。更增加了我的怀疑。于是在命令行下进入
Microsoft Visual Studio 8/Common7/Tools目录中,执行vsvars32.bat,再查看path环境变量,已经修改为vc8的。再进入stlport的build/lib目录,将vc8.mak的/Wp64标志恢复
执行nmake /fmsvc.mak ,报告错误说pdb文件是老的格式,删除后再编译, 这次没有任何错误和警告,生成顺利。
再编译测试程序,没有任何错误,执行正确。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: