我试图在Visual 2010下的C++游戏中使用C++(使用C++包装器),但是链接器拒绝链接库。
我按照INSTALL.txt文件构建了这个库,并在C中有一个physfs.lib:\physfs.lib-2.0.2\lib\Debug,但是它告诉我它找不到符号。但是,它肯定可以找到.lib文件,因为如果我更改了库路径或库名,就会引发一个错误。
我完全被这弄糊涂了,有人能帮忙吗?这是我的装置:
VC++目录->库目录
C:\include\glew-1.7.0\lib
C:\include\boost_1_47_0\libs\
C:\include\glfw-2.7.2\lib
C:\include\glfw-2.7.2\lib\win32
C:\include\boost_1_47_0\stage\lib\
c:\include\allegro-5.0.5-msvc-10.0\lib
C:\include\physfs-2.0.2\lib\Debug
$(LibraryPath)链接器->输入->附加依赖项
physfs.lib
glew32d.lib
GLFW.lib
opengl32.lib
allegro-5.0.5-md-debug.lib
allegro_dialog-5.0.5-md-debug.lib
%(AdditionalDependencies)构建输出
1>------ Build started: Project: Wolfenstein3D2011, Configuration: Debug Win32 ------
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Wolfenstein3D2011.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getDirSeparator referenced in function "void __cdecl PhysFS::`dynamic initializer for 'DIR_SEP''(void)" (??__EDIR_SEP@PhysFS@@YAXXZ)
1>PhysFS.obj : error LNK2001: unresolved external symbol __imp__PHYSFS_getDirSeparator
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_permitSymbolicLinks referenced in function "void __cdecl PhysFS::init(char const *,bool)" (?init@PhysFS@@YAXPBD_N@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getLastError referenced in function "void __cdecl PhysFS::init(char const *,bool)" (?init@PhysFS@@YAXPBD_N@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_init referenced in function "void __cdecl PhysFS::init(char const *,bool)" (?init@PhysFS@@YAXPBD_N@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_deinit referenced in function "void __cdecl PhysFS::deinit(void)" (?deinit@PhysFS@@YAXXZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_isInit referenced in function "bool __cdecl PhysFS::isInit(void)" (?isInit@PhysFS@@YA_NXZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_supportedArchiveTypes referenced in function "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl PhysFS::supportedArchiveTypes(void)" (?supportedArchiveTypes@PhysFS@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@XZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_freeList referenced in function "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl PhysFS::getCdRomDirs(void)" (?getCdRomDirs@PhysFS@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@XZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getCdRomDirs referenced in function "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl PhysFS::getCdRomDirs(void)" (?getCdRomDirs@PhysFS@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@XZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_addToSearchPath referenced in function "void __cdecl PhysFS::addToSearchPath(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?addToSearchPath@PhysFS@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_removeFromSearchPath referenced in function "void __cdecl PhysFS::removeFromSearchPath(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?removeFromSearchPath@PhysFS@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_mount referenced in function "void __cdecl PhysFS::mount(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?mount@PhysFS@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0_N@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getMountPoint referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl PhysFS::getMountPoint(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getMountPoint@PhysFS@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getSearchPath referenced in function "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl PhysFS::getSearchPath(void)" (?getSearchPath@PhysFS@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@XZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getUserDir referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __cdecl PhysFS::getUserDir(void)" (?getUserDir@PhysFS@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getBaseDir referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __cdecl PhysFS::getBaseDir(void)" (?getBaseDir@PhysFS@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getWriteDir referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl PhysFS::getWriteDir(void)" (?getWriteDir@PhysFS@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_setWriteDir referenced in function "void __cdecl PhysFS::setWriteDir(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?setWriteDir@PhysFS@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_setSaneConfig referenced in function "void __cdecl PhysFS::setSaneConfig(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool,bool)" (?setSaneConfig@PhysFS@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00_N1@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_exists referenced in function "bool __cdecl PhysFS::exists(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?exists@PhysFS@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_isDirectory referenced in function "bool __cdecl PhysFS::isDirectory(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?isDirectory@PhysFS@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_isSymbolicLink referenced in function "bool __cdecl PhysFS::isSymbolicLink(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?isSymbolicLink@PhysFS@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getLastModTime referenced in function "__int64 __cdecl PhysFS::getLastModTime(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getLastModTime@PhysFS@@YA_JABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_mkdir referenced in function "void __cdecl PhysFS::mkdir(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?mkdir@PhysFS@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_delete referenced in function "void __cdecl PhysFS::remove(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?remove@PhysFS@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_getRealDir referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl PhysFS::getRealDir(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getRealDir@PhysFS@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_enumerateFiles referenced in function "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl PhysFS::enumerateFiles(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?enumerateFiles@PhysFS@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_openAppend referenced in function "public: __thiscall PhysFS::FileDevice::FileDevice(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum PhysFS::OpenMode)" (??0FileDevice@PhysFS@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4OpenMode@1@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_openWrite referenced in function "public: __thiscall PhysFS::FileDevice::FileDevice(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum PhysFS::OpenMode)" (??0FileDevice@PhysFS@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4OpenMode@1@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_openRead referenced in function "public: __thiscall PhysFS::FileDevice::FileDevice(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum PhysFS::OpenMode)" (??0FileDevice@PhysFS@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4OpenMode@1@@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_close referenced in function "public: void __thiscall PhysFS::FileDevice::close(void)" (?close@FileDevice@PhysFS@@QAEXXZ)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_read referenced in function "public: __int64 __thiscall PhysFS::FileDevice::read(char *,__int64)" (?read@FileDevice@PhysFS@@QAE_JPAD_J@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_write referenced in function "public: __int64 __thiscall PhysFS::FileDevice::write(char const *,__int64)" (?write@FileDevice@PhysFS@@QAE_JPBD_J@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_seek referenced in function "public: class std::fpos<int> __thiscall PhysFS::FileDevice::seek(__int64,int)" (?seek@FileDevice@PhysFS@@QAE?AV?$fpos@H@std@@_JH@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_fileLength referenced in function "public: class std::fpos<int> __thiscall PhysFS::FileDevice::seek(__int64,int)" (?seek@FileDevice@PhysFS@@QAE?AV?$fpos@H@std@@_JH@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_tell referenced in function "public: class std::fpos<int> __thiscall PhysFS::FileDevice::seek(__int64,int)" (?seek@FileDevice@PhysFS@@QAE?AV?$fpos@H@std@@_JH@Z)
1>PhysFS.obj : error LNK2019: unresolved external symbol __imp__PHYSFS_flush referenced in function "public: bool __thiscall PhysFS::FileDevice::flush(void)" (?flush@FileDevice@PhysFS@@QAE_NXZ)
1>C:\Users\Lexi\OpenGL\wulfgame\game\Wolfenstein3D2011.exe : fatal error LNK1120: 37 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========发布于 2012-01-07 17:06:58
最后,我发现问题是CMake自动将PhysFS的构建定向到静态的win64库,而我的项目则希望它是一个共享的win32 dll。
我通过重新配置解决了静态/共享问题,但是找不到任何设置机器架构的东西。(大概有一些东西,但我对CMake一无所知。)
我的最后解决办法是:
在此之后,它编译成一个链接完美的win32 dll。哇哦。
发布于 2012-01-07 15:36:44
根本的问题是最上面的警告
链接:警告LNK4098: defaultlib 'MSVCRT‘与其他库的冲突;使用/NODEFAULTLIB:library
这里的编译器是说,项目链接的所选择的C运行时库与某些/所有库所选择的版本冲突。显然,这会导致它不使用标准库,并且您最终会得到一个链接器错误流,用于其中定义的类型。
您需要为所有的库和这个项目选择一个单一版本的C运行时。然后对它们进行编译。
https://stackoverflow.com/questions/8770135
复制相似问题