1

我正在尝试在 Visual Studio 2010 下的 C++ 游戏(使用C++ 包装器)中使用PhysFS,但链接器拒绝链接库。 我根据 INSTALL.txt 文件构建了库,并在C:\include\physfs-2.0.2\lib\Debug中有一个 physfs.lib ,但它告诉我它找不到符号。但是,它肯定可以找到 .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 ==========
4

2 回答 2

1

我最终(在其他人的一些指导下)发现问题是 CMake 自动将 PhysFS 的构建定位到静态 win64 库,而我的项目期望它是一个共享的 win32 dll。
我通过重新配置解决了静态/共享问题,但我找不到任何设置机器架构的东西。(大概有什么,但我对CMake一无所知。)
我的最终解决方案:

  1. 使用仅共享的选项进行干净的 CMake 配置。
  2. Build->Configuration Manager添加 Win32 作为平台并禁用 test_physfs
  3. 在 phyfs 的Project->Properties->Linker->Advanced中,将Target Machine设置为MachineX86
  4. Linker->Command Line中,从Additional Options中删除/MACHINE:X64(这个让我发疯,直到我偶然发现它)

之后,它编译成一个完美链接的win32 dll。呜。

于 2012-01-07T17:06:58.367 回答
0

根本问题是最顶部的这个警告

链接:警告 LNK4098:defaultlib 'MSVCRT' 与使用其他库冲突;使用 /NODEFAULTLIB:library

此处的编译器说,您的项目链接的所选 C 运行时库与您的部分/所有库选择的版本冲突。这显然导致它不使用标准库,并且您最终会遇到其中定义的类型的链接器错误流。

你需要为你的所有库和这个项目选择一个单一版本的 C 运行时。然后针对它编译它们。

于 2012-01-07T15:36:44.867 回答