I am using Netbeans as IDE and have been trying to build a piece of code which uses boost library, but I am getting below error
g++ -c -g -MMD -MP -MF "build/Debug/GNU-Linux-x86/tcpproxy_server.o.d" -o build/Debug/GNU-Linux-x86/tcpproxy_server.o tcpproxy_server.cpp mkdir -p dist/Debug/GNU-Linux-x86 g++ -o dist/Debug/GNU-Linux-x86/tcp_proxy build/Debug/GNU-Linux-x86/tcpproxy_server.o build/Debug/GNU-Linux-x86/tcpproxy_server.o: In function
__static_initialization_and_destruction_0(int, int)': /usr/include/boost/system/error_code.hpp:221: undefined reference to
boost::system::generic_category()' /usr/include/boost/system/error_code.hpp:222: undefined reference toboost::system::generic_category()' /usr/include/boost/system/error_code.hpp:223: undefined reference to
boost::system::system_category()' build/Debug/GNU-Linux-x86/tcpproxy_server.o: In functionboost::system::error_code::error_code()': /usr/include/boost/system/error_code.hpp:322: undefined reference to
boost::system::system_category()' build/Debug/GNU-Linux-x86/tcpproxy_server.o: In functionboost::asio::error::get_system_category()': /usr/include/boost/asio/error.hpp:230: undefined reference to
boost::system::system_category()' build/Debug/GNU-Linux-x86/tcpproxy_server.o: In functionboost::thread_exception::thread_exception(int, char const*)': /usr/include/boost/thread/exceptions.hpp:51: undefined reference to
boost::system::system_category()' collect2: error: ld returned 1 exit status
So I did some online search for error and found out that I have to add "-lboost_system" in my compile command.
I added it in "project->properties->build->c++ compiler-> Additional Options" but still the same error.
g++ -lboost_system -o dist/Debug/GNU-Linux-x86/tcp_proxy build/Debug/GNU-Linux-x86/tcpproxy_server.o build/Debug/GNU-Linux-x86/tcpproxy_server.o: In function
__static_initialization_and_destruction_0(int, int)': /usr/include/boost/system/error_code.hpp:221: undefined reference to
boost::system::generic_category()' /usr/include/boost/system/error_code.hpp:222: undefined reference toboost::system::generic_category()' /usr/include/boost/system/error_code.hpp:223: undefined reference to
boost::system::system_category()' build/Debug/GNU-Linux-x86/tcpproxy_server.o: In functionboost::system::error_code::error_code()': /usr/include/boost/system/error_code.hpp:322: undefined reference to
boost::system::system_category()' build/Debug/GNU-Linux-x86/tcpproxy_server.o: In functionboost::asio::error::get_system_category()': /usr/include/boost/asio/error.hpp:230: undefined reference to
boost::system::system_category()' build/Debug/GNU-Linux-x86/tcpproxy_server.o: In functionboost::thread_exception::thread_exception(int, char const*)': /usr/include/boost/thread/exceptions.hpp:51: undefined reference to
boost::system::system_category()' collect2: error: ld returned 1 exit status
I found out that I have to add it in the end of compile line, for example :
"g++ tcp_proxy.cpp -o tcpproxy -lboost_system"
This I tried and its working, but netbeans is adding "Addition Options" at the start
like:
g++ -lboost_system -o dist/Debug/GNU-Linux-x86/tcp_proxy build/Debug/GNU-Linux-x86/tcpproxy_server.o
Is there any way I can configure netbeans to add my option in end ?