#46202 closed defect (invalid)
Undefined symbols for architecture x86_64 on Yosemite
Reported by: | nmsnoopy@… | Owned by: | macports-tickets@… |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.3.3 |
Keywords: | Cc: | ryandesign (Ryan Carsten Schmidt), jamesrome@… | |
Port: | log4cpp |
Description
hello,
First of all thanks a lot to have solved my first ticket : #46178, I resintalled from scratch gcc48 and now gcc48 works.
The problem I have now(and from the beginning in fact) is a linking problem on Yosemite. Here below I added a simple code using the log4cpp library which fails at the link level. I have only installed the gcc48, log4cpp and boost ports (Note that the same program does not fail on Mavericks). Thanks to help me on this.
The link error is:
> g++ -o test4 test4.cpp -L/opt/local/lib -llog4cpp Undefined symbols for architecture x86_64: "log4cpp::OstreamAppender::OstreamAppender(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_ostream<char, std::char_traits<char> >*)", referenced from: _main in cc8Xtd0v.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status
The example code:
#include "log4cpp/Category.hh" #include "log4cpp/Appender.hh" #include "log4cpp/OstreamAppender.hh" int main(int argc, char** argv) { log4cpp::Appender *appender1 = new log4cpp::OstreamAppender("console", &std::cout); return 0; }
Attachments (1)
Change History (5)
comment:1 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)
Cc: | ryandesign@… added |
---|---|
Keywords: | linker removed |
Priority: | High → Normal |
Resolution: | → invalid |
Status: | new → closed |
comment:2 Changed 10 years ago by nmsnoopy@…
Now it's clear! It's working now. Thanks a lot for your help, it was precious.
comment:3 Changed 9 years ago by jamesrome@…
I get this same thing using gcc: ld: symbol(s) not found for architecture x86_64 I did sudo port select gcc to select gcc5. See attached for my tool choices in NetBeans.
comment:4 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)
Cc: | jamesrome@… added |
---|
James, this ticket is about a problem mixing two different C++ compilers; you've told us on the mailing list already that you're only using C code, so your problem is not related to this ticket. This ticket is closed and marked invalid and we should not be adding to it. Please continue to discuss your issue on the macports-users mailing list rather than in this issue tracker.
Assuming that "
g++
" is a symlink to g++ from a MacPorts gcc port, for example created by using "sudo port select
" to select a MacPorts gcc, or created manually, then this failure is expected.Like most ports, log4cpp is built using the system compiler. As of Lion, that's clang. That means it's using the system C++ library, which as of Mavericks is libc++.
g++ from gcc48, and g++ from any FSF gcc port in MacPorts, uses the libstdc++ library from gcc.
You cannot mix the two libraries in the same process and be able to pass objects back and forth between them. See wiki:FAQ#libcpp
If you need more information about this situation you can write to the macports-users mailing list but it's not exactly a bug and it's not something we're likely to be able to fix.
The solution is to use clang++ instead of g++.