4

Trying to build Websocket ++ with MinGW: last linker errors & mdash; What co...

 2 years ago
source link: https://www.codesd.com/item/trying-to-build-websocket-with-mingw-last-linker-errors-what-could-it-be.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Trying to build Websocket ++ with MinGW: last linker errors & mdash; What could it be?

advertisements

Attempting to build websocket++ for Windows.

g++ -Wall -O2  -I/c/boost/boost_1_52_0//boost chat_server.o chat.o -o chat_server -L/c/boost/boost_1_52_0//stage/lib ../../libwebsocketpp.a /c/boost/boost_1_52_0//stage/lib/libboost_system-mgw46-mt-1_52.a c/boost/boost_1_52_0//stage/lib/libboost_date_time-mgw46-mt-1_52.a c/boost/boost_1_52_0//stage/lib/libboost_program_options-mgw46-mt-1_52.a c/boost/boost_1_52_0//stage/lib/libboost_thread-mgw46-mt-1_52.a /c/boost/boost_1_52_0//stage/lib/libboost_regex-mgw46-mt-1_52.a -lpthread -lws2_32 -lmswsock
chat_server.o:chat_server.cpp:(.text$_ZN5boost6detail17sp_counted_impl_pINS_6threadEE7disposeEv[boost::detail::sp_counted_impl_p<boost::thread>::dispose()]+0x14): undefined reference to `_imp___ZN5boost6threadD1Ev'
chat_server.o:chat_server.cpp:(.text$_ZN5boost14checked_deleteINS_6threadEEEvPT_[void boost::checked_delete<boost::thread>(boost::thread*)]+0x11): undefined reference to `_imp___ZN5boost6threadD1Ev'
chat_server.o:chat_server.cpp:(.text$_ZN11websocketpp4role6serverINS_8endpointIS1_NS_6socket5plainENS_3log6loggerEEEE12start_listenERKN5boost4asio2ip14basic_endpointINSB_3tcpEEEj[websocketpp::role::server<websocketpp::endpoint<websocketpp::role::server, websocketpp::socket::plain, websocketpp::log::logger> >::start_listen(boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> const&, unsigned int)]+0x307): undefined reference to `_imp___ZN5boost6thread12start_threadEv'
collect2: ld returned 1 exit status
make: *** [chat_server] Error 1

Don't mind the double-slashes in the paths, it's from me being sloppy editing makefiles.

I had to compile boost 1.52 using MinGW also.

The linker can't seem to find boost::thread and boost::thread::start_thread.


It looks like boost wants to link to the DLL version of the boost::thread library. See http://www.boost.org/doc/libs/1_52_0/doc/html/thread/build.html for the rather convoluted documentation on how boost can/should be configured to use static or dynamic libraries for boost::thread.

You should be able to solve your problem by linking to the DLL version of the library instead of the static version. You might also be able to solve your problem by defining BOOST_THREAD_USE_LIB when compiling to configure the use of the static thread lib. However I'm not sure whether or not the MinGW compiler supports the automatic tss cleanup that the static library relies on to clean up properly when threads exit.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK