I am trying to setup logging using boost in my project and I am spending some time to learn the library. However a simple example, taken from the official tutorial crashes.
#include <boost/log/trivial.hpp>
int main(int, char*[])
{
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
return 0;
}
I am trying to build with CMake using the following commands
g++ -std=c++11 -Wall -pedantic -g -O0 -DBOOST_LOG_DYN_LINK -c main.cpp
g++ main.o -lpthread -lboost_log -o main
After compiling and running ./main, I am getting segmentation fault. Why? Is it something wrong with boost log? Did I miss something obvious?
The gdb output might help
Breakpoint 1, main () at main.cpp:6
6 BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
(gdb) n
*** Error in `/home/administrator/lef/bdg3/tests/logging/main': free(): invalid pointer: 0x00007ffff78e11f8 ***
Program received signal SIGABRT, Aborted.
0x00007ffff6cb5267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
55 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.