如何将Boost库添加到Visual Studio Linux项目? [英] How to add boost libraries to a Visual Studio Linux project?

查看:196
本文介绍了如何将Boost库添加到Visual Studio Linux项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个小型聊天服务器,该服务器已经在Windows上进行了测试和编译,没有任何问题.下一步是将该服务器放在我的Raspberry Pi上.但是到那时,我遇到了很多错误.

I have created a little chat server which I have tested and compiled on Windows without any problems. The next step would be to put this server on my Raspberry Pi. But at that point I'm getting many errors.

我创建了一个Visual Studio远程Linux项目,该项目已连接到我的Raspberry Pi.我认为编译器找不到这些库.

I created a Visual Studio Remote Linux Project which I have conntected to my Raspberry Pi. I think that the compiler cannot find the libraries.

我得到一些错误(总错误大约为700):

Some errors which I get(total errors are about 700):

-错误(活动)E0304没有重载函数"boost :: asio :: buffer"的实例与参数列表匹配 -错误(有效)E0020标识符"sa_family_t"是未定义的VoiceChatServer -在常量表达式中不允许发生错误(活动)E0059函数 -错误(有效)E2778内置函数不可用,因为不支持矢量类型 -Error(活动)E0035 #error指令:仅支持Windows,POSIX和std :: thread!

-Error (active) E0304 no instance of overloaded function "boost::asio::buffer" matches the argument list -Error (active) E0020 identifier "sa_family_t" is undefined VoiceChatServer -Error (active) E0059 function call is not allowed in a constant expression -Error (active) E2778 builtin function is not available because vector types are not supported -Error (active) E0035 #error directive: Only Windows, POSIX and std::thread are supported!

我的项目属性如下所示: VC ++目录>包含目录:C:\ Program Files \ Cpp_Libs \ boost_1_66_0, /home/pi/boostPrefix/include/, C:\ includeLinux \ include, /usr/include/

My Project Properties look like that: VC++ Directories > Include Directories: C:\Program Files\Cpp_Libs\boost_1_66_0, /home/pi/boostPrefix/include/, C:\includeLinux\include, /usr/include/

C/C ++>其他包含目录:C:\ Program Files \ Cpp_Libs \ boost_1_66_0, /home/pi/boostPrefix/include/, C:\ includeLinux \ include, /usr/include/

C/C++ > Additional Include Directories: C:\Program Files\Cpp_Libs\boost_1_66_0, /home/pi/boostPrefix/include/, C:\includeLinux\include, /usr/include/

链接器>其他库目录:/home/pi/boostPrefix/lib/, C:\ Program Files \ Cpp_Libs \ boost_1_66_0 \ stage \ lib

Linker > Additional Library Directories: /home/pi/boostPrefix/lib/, C:\Program Files\Cpp_Libs\boost_1_66_0\stage\lib

有人知道如何正确包含库吗?

Does anybody know how to include the libraries correctly?

推荐答案

boost :: asio是仅标头的库,即您只需在包含目录路径中指定boost :: asio源的路径,但它确实取决于其他一些带有编译二进制文件的库(目标文件).您必须在Visual Studio项目的Linker - Input - Library Dependencies下列出这些附加库.例如.对于Boost.System,请指定boost_system,链接器将添加lib前缀和.a.so扩展名.

boost::asio is a header-only library, i.e. you simply specify the path to boost::asio source in the include directory path but it does depend on some other libraries with compiled binaries (object files). You must list these additonal libraries in the Visual Studio project under Linker - Input - Library Dependencies. E.g. in the case of Boost.System specify boost_system and the linker will add the lib prefix and .a or .so extension.

这是在Linux上必须做的额外事情,在Windows Boost上会通过Visual Studio指令自动添加库引用.

This is something extra you must do on Linux, on Windows Boost automatically adds the library references thru a Visual Studio directive.

我很好奇您如何安装Boost;在我看来,您在Linux遥控器上的包含路径为/home/pi/boostPrefix/include.如果遵循标准的Boost安装过程(boostrap.shb2),Boost标头将位于/.../boost_1_66_0/boost/asio中,则在Visual Studio项目C/C++ > Additional Include Directories中指​​定的包含路径将为/.../boost_1_66_0,并且在C ++中您将编写#include <boost/asio>

I'm curious about how you've installed Boost; it looks to me like your include path on the Linux remote is /home/pi/boostPrefix/include. If you have followed the standard Boost install procedure (boostrap.sh and b2) the Boost headers will be in /.../boost_1_66_0/boost/asio, the include path you specify in the Visual Studio project C/C++ > Additional Include Directories will be /.../boost_1_66_0 and in your C++ code you will write #include <boost/asio>

顺便说一句,您无需在库路径中指定/usr/include,默认情况下,GCC会在其中查找.

Incidentally, you do not need to specify /usr/include in the library path, GCC looks there by default.

这篇关于如何将Boost库添加到Visual Studio Linux项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆