首页 文章

g构建具有boost依赖性的c程序

提问于
浏览
0

我想在windows上编译并运行一个简单的c websocket应用程序 .

Boost的安装方式如下:

./bootstrap.bat mingw
./b2.exe install --prefix=C:/boostLibs toolset=gcc

我的c包括这样的:

#include <websocketpp/config/asio_no_tls.hpp>

#include <websocketpp/server.hpp>

#include <iostream>

此websocket样本由https://github.com/zaphoyd/websocketpp提供

为了构建项目,我发出以下命令:

g++ -Wno-deprecated -I ./cppServer/libs/ -I C:\boostLibs\include\boost-1_55 -L C:\boostLibs\lib -g ./cppServer/server.cpp -lboost_system

这让我误以为这个错误信息:

c:/ mingw / bin /../ lib / gcc / mingw32 / 6.3.0 /../../../../ mingw32 / bin / ld.exe:找不到-lboost_system collect2.exe:错误:ld返回1退出状态

如果我尝试在没有-lboost_system的情况下构建,我会得到一个非常长的异常,从以下开始:

C:/boostLibs/include/boost-1_55/boost/system/error_code.hpp:222:对boost :: system :: generic_category()的未定义引用'C:/ boostLibs / include / boost-1_55 / boost / system / error_code.hpp:223:undefined reference toboost :: system :: generic_category()'C:/boostLibs/include/boost-1_55/boost/system/error_code.hpp:224:对boost :: system :: system_category的未定义引用( )'C:\ Users \ JOHANN~1.HAS \ AppData \ Local \ Temp \ ccpKMWTH.o:在functionZN5boost6system10error_codeC1Ev':C:/boostLibs/include/boost-1_55/boost/system/error_code.hpp:323:undefined reference to boost :: system :: system_category()'C:\ Users \ JOHANN~1.HAS \ AppData \ Local \ Temp \ ccpKMWTH.o:在functionZN5boost6system4errc20make_error_conditionENS1_6errc_tE':C:/ boostLibs / include / boost-1_55 / boost / system /error_code.hpp:488:对boost :: system :: generic_category()的未定义引用'C:\ Users \ JOHANN~1.HAS \ AppData \ Local \ Temp \ ccpKMWTH.o:在functionZN5boost16thread_exceptionC2EiPKc'中

那我错过了什么?我现在无法理解 .

1 回答

  • 0

    链接到 boost_system-lboost_system-mgw63-mt-1_55 ,因为这是这些文件的调用 . 有关详细信息,请参阅boost library naming .

    当您构建boost时,您可能希望将 --layout=system 指定为 b2.exe ,以便您的文件在文件名中没有 -mgw63-mt-1_55 ,然后在链接时使用 -lboost_system .

相关问题