运行时出现以下错误:
无法在动态链接库“test.exe”中找到过程入口点
_ZSt24__throw_out_of_range_fmtPKcz
。
我使用C ++ demangler来找出导致入口点错误的函数。
功能是:std::__throw_out_of_range_fmt(char const*, ...)
我正在链接到以下库:
我使用与我在项目中使用的相同版本的GCC从源代码编译SDL2因为我认为我使用的预构建版本在某种程度上导致了不同C ++标准库中的冲突。然后我尝试动态链接到此构建,但完全相同的运行时错误仍然存在。
编译&链接脚本日志(通过Windows BATCH脚本编译):
C:\Users\Harrand\Desktop\Ocular GEng\src\camera.o
C:\Users\Harrand\Desktop\Ocular GEng\src\datatranslation.o
C:\Users\Harrand\Desktop\Ocular GEng\src\glew.o
C:\Users\Harrand\Desktop\Ocular GEng\src\light.o
C:\Users\Harrand\Desktop\Ocular GEng\src\listeners.o
C:\Users\Harrand\Desktop\Ocular GEng\src\matrix.o
C:\Users\Harrand\Desktop\Ocular GEng\src\mesh.o
C:\Users\Harrand\Desktop\Ocular GEng\src\model_loader.o
C:\Users\Harrand\Desktop\Ocular GEng\src\object.o
C:\Users\Harrand\Desktop\Ocular GEng\src\quaternion.o
C:\Users\Harrand\Desktop\Ocular GEng\src\shader.o
C:\Users\Harrand\Desktop\Ocular GEng\src\stb_image.o
C:\Users\Harrand\Desktop\Ocular GEng\src\test.o
C:\Users\Harrand\Desktop\Ocular GEng\src\texture.o
C:\Users\Harrand\Desktop\Ocular GEng\src\timekeeper.o
C:\Users\Harrand\Desktop\Ocular GEng\src\utility.o
C:\Users\Harrand\Desktop\Ocular GEng\src\vector.o
C:\Users\Harrand\Desktop\Ocular GEng\src\window.o
C:\Users\Harrand\Desktop\Ocular GEng\src\world.o
19 file(s) moved.
Compilation Completed, ".o" files are in "C:\Users\Harrand\Desktop\Ocular GEng\cpl\Thu 08.25.2016"
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls
Thread model: win32
gcc version 4.9.3 (GCC)
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../
COLLECT_GCC_OPTIONS='-v' '-LC:\Users\Harrand\Desktop\Ocular GEng\lib' '-LC:\Users\Harrand\Desktop\Ocular GEng\Lua\5.3.2\lib' '-o' 'oculargame-test.exe' '-shared-libgcc' '-mtune=generic' '-march=i586'
c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/collect2.exe -plugin c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/liblto_plugin-0.dll -plugin-opt=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\Harrand\AppData\Local\Temp\ccUhcnbk.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -Bdynamic -u ___register_frame_info -u ___deregister_frame_info -o oculargame-test.exe c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/4.9.3/crtbegin.o -LC:\Users\Harrand\Desktop\Ocular GEng\lib -LC:\Users\Harrand\Desktop\Ocular GEng\Lua\5.3.2\lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.9.3 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../.. camera.o datatranslation.o glew.o light.o listeners.o matrix.o mesh.o model_loader.o object.o quaternion.o shader.o stb_image.o test.o texture.o timekeeper.o utility.o vector.o window.o world.o -lOpenGL32 -lSDL2 -lSDL2main C:\Users\Harrand\Desktop\Ocular GEng\res\exe\ocular.res -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.9.3/crtend.o
1 file(s) moved.
Linking Completed, "oculargame-test.exe" is in "C:\Users\Harrand\Desktop\Ocular GEng\cpl\Thu 08.25.2016\lnk"
在运行期间仅打印错误消息是此问题的标题。我正在链接到以下库:
我只链接到动态链接库libSDL2.dll。我之前的怀疑是因为SDL2是在我自己编译之前预先构建的,所以在编译器版本中存在冲突。但是,我现在知道事实并非如此。这个错误可能是由于我将GLEW源代码添加到我的项目中而引起的吗?
答案 0 :(得分:1)
我最初的怀疑是不正确的但是在正确的轨道上:我打算使用的MinGW版本与很久以前我安装到系统路径中的MinGW版本不同。这样做的结果是,可执行文件对G ++ DLL的依赖性默认情况下是针对我安装的MinGW版本的DLL;错误的版本。这导致运行时错误。
通过替换以下内容解决了此问题:
"C:\MinGW\bin\g++"*.o -L%libdir% -L"%scriptdir%\Lua\5.3.2\lib" -lOpenGL32 -lSDL2 -lSDL2main "%scriptdir%\res\exe\ocular.res" -o "oculargame-test.exe"
与
"C:\MinGW\bin\g++" -static-libgcc -static-libstdc++ *.o -L%libdir% -L"%scriptdir%\Lua\5.3.2\lib" -lOpenGL32 -lSDL2 -lSDL2main "%scriptdir%\res\exe\ocular.res" -o "oculargame-test.exe"
我在命令中添加了标志-static-libgcc -static-libstdc++
,以便我想使用的MinGW版本(在" C:\ MinGW \ bin"中)将依赖关系静态链接到可执行文件中,以便冲突不会发生。我希望这可以帮助其他人处理同样棘手的问题。