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.
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.
Some errors which I get(total errors are about 700):
-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!
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++ > Additional Include Directories: C:\Program Files\Cpp_Libs\boost_1_66_0, /home/pi/boostPrefix/include/, C:\includeLinux\include, /usr/include/
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 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 specifyboost_system
and the linker will add thelib
prefix and.a
or.so
extension.This is something extra you must do on Linux, on Windows Boost automatically adds the library references thru a Visual Studio directive.
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
andb2
) the Boost headers will be in/.../boost_1_66_0/boost/asio
, the include path you specify in the Visual Studio projectC/C++ > Additional Include Directories
will be/.../boost_1_66_0
and in your C++ code you will write#include <boost/asio>
Incidentally, you do not need to specify
/usr/include
in the library path, GCC looks there by default.