近三天来,我一直在尝试使用 mingw 让 boost 库在 CodeBlocks 中正常工作。在我自己设法解决的许多问题之间,现在我被困住了,这让我发疯。
我已经多次使用发送到的不同标志构建了该库,bjam
但每次在 CodeBlocks 中使用这些库时,我都会得到相同的结果。很多行与
undefined reference to `___gxx_personality_sj0'
undefined reference to `__Unwind_SjLj_Register'
undefined reference to `__Unwind_SjLj_Resume'
undefined reference to `__Unwind_SjLj_Unregister'
在人们开始抨击我之前,我在来这里之前已经搜索了问题。几乎所有的线程(这里和这里以及其他)都说这个问题来自于 boost 是用编译器构建的,现在我试图在 CodeBlocks 中使用另一个不同的编译器。我一次又一次地检查,我只有一个MinGW
可用的安装。我检查了我的Path
变量,里面没有任何不需要的东西,只有我想使用的 MinGW 的 bin 文件夹。我没有安装任何 QT,所以从那里没有第二个 MinGW。另外,我下载了没有捆绑 MinGW 的 CodeBlocks。
下面我将列出我采取的步骤:
1)bootstrap.bat mingw
构建 bjam
2)如此处bjam --toolset=gcc "--prefix=<installpath>" install
所述
3)按照步骤2中的链接中的其余步骤进行操作)
4) 添加Boost.Filesystem
, Boost.System
,Boost.DateTime
和(Boost.LogBoost.Thread
的Boost.Regex
依赖项取自这里)
5)复制/粘贴此示例
我尝试构建时 CodeBlocks 使用的命令:
mingw32-g++.exe -Wall -fexceptions -g
-ID:\libs\boost\include\boost-1_51 -c D:\example\example\main.cpp -o obj\Debug\main.omingw32-g++.exe -LD:\libs\boost\lib -o bin\Debug\example.exe obj\Debug\main.o D:\libs\boost\lib\libboost_filesystem-mgw44-mt-d-1_51.a D:\libs\boost\lib\libboost_system-mgw44-mt-d-1_51.a D:\libs\boost\lib\libboost_date_time-mgw44-mt-d-1_51.a D:\libs\boost\lib\libboost_thread -mgw44-mt-1_51.a D:\libs\boost\lib\libboost_regex-mgw44-mt-d-1_51.a D:\libs\boost\lib\libboost_log_setup-mgw44-mt-d-1_51.a
还有什么可能是造成这种情况的原因?
后来补充:
CodeBlocks 工具链可执行文件是:
c++ compiler: mingw32-g++.exe
linker for dynamic libs: mingw32-g++.exe
linker for static libs: ar.exe
所有 .EXE 都在它们应该在的位置,但添加此信息可能很重要。