missing lboost_thread-mt in mongodb cpp driver (ubuntu server x64)
Page http://packages.ubuntu.com/saucy/i386/libboost-thread1.54-dev/filelist shows that Ubuntu libboost-thread package has libboost_thread.so library file, not libboost_thread-mt.so
So, correct command is:
root@server:/home/user/Desktop# g++ mongotest.cpp -pthread -lmongoclient -lboost_thread -lboost_filesystem -lboost_program_options -lboost_system -o tutorial
/usr/bin/ld: cannot find -lboost_thread-lpthread
I think you need a space between -lboost_thread and -lpthread in your command line.
How to compile C++ mongo project
You need to use -I and -L to specify where you have installed your mongo header(s) and library(ies):
g++ tutorial.cpp -I/path/to/mongo/include/ -pthread -L/path/to/libmongoclient
-lboost_thread-mt -lboost_filesystem -lboost_program_options
-lboost_system -o tutorial
compile with boost on ubuntu 14.04 : undefined reference to `boost::thread::get_id() const'
/home/khan/git/sdkLinux/libFingiSdk/Debug/libfingidevicesdk.so: undefined reference to `boost::thread::get_id() const'
You need to link libfingidevicesdk.so
with the boost thread library as well.
Linkage error with Boost Log 1.65.0 example from the Boost.org
I'm answering my own question, following the @Praetorian help and suggestion.
The Boost Log
relies on two libraries (I thought it was only one):
hekto@ubuntu:~$ ls -l /usr/lib/x86_64-linux-gnu/libboost_log*
-rw-r--r-- 1 root root 3510082 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log.a
-rw-r--r-- 1 root root 2441460 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log_setup.a
lrwxrwxrwx 1 root root 28 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log_setup.so -> libboost_log_setup.so.1.65.1
-rw-r--r-- 1 root root 671944 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log_setup.so.1.65.1
lrwxrwxrwx 1 root root 22 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log.so -> libboost_log.so.1.65.1
-rw-r--r-- 1 root root 905752 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log.so.1.65.1
If you compile and link on Linux, you'll have to provide a list of Boost libraries on the command line. According to an answer to this question, given by the main developer (@AndreySemashev) of the Boost Log
, these libraries on the command line should look like this:
-lboost_log_setup -lboost_log
Probably it makes sense to provide two libraries instead of one (for example, when you link statically), but I couldn't find any recommendations about when we should use a single library, and when - both of them.
Related Topics
How to Know If One Shared Library Depends on Another Shared Library or Not
Opencv Videocapture Lag Due to the Capture Buffer
Std::Fstream Doesn't Create File
How to Read/Write Arbitrary Bits in C/C++
How to Simulate "Press Any Key to Continue"
C++11: Correct Std::Array Initialization
Access Variable Value Using String Representing Variable's Name in C++
Memset() or Value Initialization to Zero Out a Struct
What Is Value of Eof and '\0' in C
System("Command") Produces an Error; But It Works When Invoked Directly from Bash Prompt
C++ Fast Screenshots in Linux for Use with Opencv
Altering Dll Search Path for Static Linked Dll
In Which Order Should Floats Be Added to Get the Most Precise Result
Is There Any "Standard" Htonl-Like Function for 64 Bits Integers in C++