运行时发生下列错误:
过程入口点
_ZSt24__throw_out_of_range_fmtPKcz无法位于动态链接库"test.exe“中。
我使用C++解析器来找出是哪个函数导致了入口点错误。其功能是:std::__throw_out_of_range_fmt(char const*, ...)
我将链接到以下图书馆:
我用我在项目中使用的GCC版本从源代码中编译了SDL2,因为我认为我正在使用的预构建版本在不同的C++标准库中引起了冲突。然后,我试图动态地链接到此构建,但完全相同的运行时错误仍然存在。
编译和链接脚本日志(通过Windows批处理脚本编译):
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"只有运行时打印的错误消息才是此问题的标题。我将链接到以下libs:
我只链接到动态链接库libSDL2.dll。我之前的猜测是,由于SDL2是在我自己编译之前就预先构建的,所以编译器版本中存在冲突。不过,我现在知道情况并非如此。这个错误是否是由于我在我的项目中添加了GLEW源代码而导致的呢?
发布于 2016-08-27 19:53:53
我最初的怀疑不是正确的,而是正确的:我打算使用的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”中)静态地将依赖项链接到可执行文件中,这样就不会发生冲突。我希望这能帮助其他人解决类似的棘手问题。
https://stackoverflow.com/questions/37945744
复制相似问题