andrew-d/cpplog — Issue #12: build error on Mac OSX Lion
Author: z00m1n
Created: 2012-02-06 04:49:37+00:00
State: open

I just git-cloned cpplog and I'm trying to use it. This is straight from the shell:

host:cpplog user$ g++ -c -o main.o main.cpp
In file included from /usr/include/c++/4.2.1/backward/strstream:51,
from main.cpp:6:
/usr/include/c++/4.2.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.

I believe this is the deprecation warning mentioned in the other bug report.

In file included from main.cpp:8:
cpplog.hpp: In member function ‘void cpplog::LogMessage::Init(const char*, unsigned int, cpplog::loglevel_t)’:
cpplog.hpp:295: error: ‘boost::interprocess::detail’ has not been declared
cpplog.hpp:296: error: ‘detail’ is not a member of ‘boost::interprocess’
cpplog.hpp:296: error: expected `;' before ‘::’ token
main.cpp: At global scope:
main.cpp:12: error: ‘detail’ is not a namespace-name
main.cpp:12: error: expected namespace-name before ‘;’ token
main.cpp: In function ‘void getLogHeader(std::string&, cpplog::loglevel_t, const char*, unsigned int)’:
main.cpp:24: error: ‘get_current_process_id’ was not declared in this scope
main.cpp:25: error: ‘get_current_thread_id’ was not declared in this scope

I haven't done a lot of C++ development recently, but I believe the required boost include file is `boost/interprocess/detail/os_thread_functions.hpp` and it seems to me it is actually found (it is located at `/usr/local/include/boost/interprocess/detail/os_thread_functions.hpp` on my system), so no idea what the problem is. Might be something simple. As a workaround, activate `#define CPPLOG_NO_SYSTEM_IDS` in `cpplog.hpp`, line 61.

main.cpp: In function ‘int TestCheckMacros()’:
main.cpp:261: warning: NULL used in arithmetic
main.cpp:265: warning: NULL used in arithmetic

(ignore that for now).

host:cpplog user$ g++ -o cpplog main.o
Undefined symbols for architecture x86_64:
"boost::thread::~thread()", referenced from:
boost::thread::operator=(boost::detail::thread_move_t)in ccAUyipp.o
cpplog::BackgroundLogger::Init() in ccAUyipp.o
cpplog::BackgroundLogger::BackgroundLogger(cpplog::BaseLogger&)in ccAUyipp.o
cpplog::BackgroundLogger::~BackgroundLogger()in ccAUyipp.o
cpplog::BackgroundLogger::~BackgroundLogger()in ccAUyipp.o
"boost::detail::get_current_thread_data()", referenced from:
boost::detail::interruption_checker::interruption_checker(_opaque_pthread_mutex_t*, _opaque_pthread_cond_t*)in ccAUyipp.o
"boost::this_thread::interruption_point()", referenced from:
boost::condition_variable::wait(boost::unique_lock&) in ccAUyipp.o
"boost::detail::thread_data_base::~thread_data_base()", referenced from:
boost::detail::thread_data, boost::_bi::list1 > > >::~thread_data()in ccAUyipp.o
boost::detail::thread_data, boost::_bi::list1 > > >::~thread_data()in ccAUyipp.o
"vtable for boost::detail::thread_data_base", referenced from:
boost::detail::thread_data_base::thread_data_base()in ccAUyipp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"boost::thread::start_thread()", referenced from:
boost::thread::thread(void (cpplog::BackgroundLogger::*)(), cpplog::BackgroundLogger*)in ccAUyipp.o
"boost::thread::thread()", referenced from:
cpplog::BackgroundLogger::BackgroundLogger(cpplog::BaseLogger&)in ccAUyipp.o
"boost::thread::join()", referenced from:
cpplog::BackgroundLogger::~BackgroundLogger()in ccAUyipp.o
cpplog::BackgroundLogger::~BackgroundLogger()in ccAUyipp.o
"typeinfo for boost::detail::thread_data_base", referenced from:
typeinfo for boost::detail::thread_data, boost::_bi::list1 > > >in ccAUyipp.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

One major advantage of using a self-proclaimed 'header only' log library is that I don't have to deal with issues around linking with other libraries. I don't need multi-threading at the moment, so activate `#define CPPLOG_NO_THREADING` in `cpplog.hpp`, line 62.

host:cpplog user$ ./cpplog
Testing logging macros... done!
Testing debug-logging macros... done!
Testing conditional macros... done!
Testing conditional macros... done!
Testing TeeLogger... done!
Testing auto-rotating loggers... (waiting) done!
Testing other logging macros... done!

------------------------------
All tests passed!

Conclusion: The two defines could be activate by default to reduce dependencies and make it easier for people to get started on cpplog.