0

I try to build C++11-project on OS X Lion (10.7.5) with clang++. All is fine, except one problem with log4cxx: after compiling I get these linker errors:

Linking CXX executable css.fcg
Undefined symbols for architecture x86_64:
  "log4cxx::FileAppender::FileAppender(log4cxx::helpers::ObjectPtrT<log4cxx::Layout> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
  "log4cxx::PatternLayout::PatternLayout(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
  "log4cxx::Level::toLevel(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
  "log4cxx::Logger::getLogger(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
  "log4cxx::Logger::info(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
  "log4cxx::Logger::warn(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
  "log4cxx::Logger::debug(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
  "log4cxx::Logger::error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
  "log4cxx::Logger::fatal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
  "log4cxx::Logger::trace(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
ld: symbol(s) not found for architecture x86_64

This is my clang++:

Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

I build project with flags -std=c++11 and -stdlib=libc++. Attempting to build project with Clang 3.2 didn't help.

Moreover, I've tried to install log4cxx library with port or with brew - same errors in both cases.

So what can I do?

IKavanagh
  • 6,089
  • 11
  • 42
  • 47
Denis Shevchenko
  • 1,342
  • 2
  • 10
  • 23
  • Do you link with `-llog4cxx` ? – Chnossos Jul 10 '14 at 00:00
  • Of course. I use `cmake 3.0` and I set `log4cxx` as required lib, so I see in `Makefile`: `/usr/bin/cmake++ ... -lmp3lame -lmemcache -lz -lpthread -lfcgi -liconv -llog4cxx -Wl,-rpath,/opt/local/lib`. And I see that `log4cxx` exists in `/usr/local/lib` (after installing with `brew`). – Denis Shevchenko Jul 10 '14 at 04:54
  • I read [this topic](http://stackoverflow.com/questions/8486077/how-to-compile-link-boost-with-clang-libc) and try to rebuild `log4cxx` like this: `brew uninstall log4cxx && brew install log4cxx --c++11`. It didn't help... – Denis Shevchenko Jul 10 '14 at 05:13
  • And this variant `brew install log4cxx --with-c++11` didn't help. – Denis Shevchenko Jul 10 '14 at 05:21
  • Maybe reason in incompatibility of `libstdc++` and `libc++`, so `log4cxx` must be compiled with `clang++` + `libc++` instead of `gcc` + `libstdc++`. Isn't it? – Denis Shevchenko Jul 10 '14 at 05:34
  • Try to `find` the libraries (`-name "*log4cxx*"`) and get the right path. They might have been installed somewhere else. On my Linux system, `pkg-config` says I need also `-lnsl` as linker flag. – edmz Jul 10 '14 at 09:30
  • I found `lib4cxx` in `/usr/local/lib`. In fact, `brew` makes a link: `~ $ liblog4cxx.dylib -> ../Cellar/log4cxx/0.10.0/lib/liblog4cxx.dylib` – Denis Shevchenko Jul 10 '14 at 11:48

0 Answers0