Linker error in MacOSX.

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Linker error in MacOSX.

Postby pupeno » Fri Feb 27, 2015 11:51 am

Hello,

I'm just getting started with CEF. I copied libcef_dll_wrapper.a from my copy of cef that I compiled on my machine using Xcode 6.1 to another project... in this case a minimalistic sample project that I'm using to learn about integrating CEF into a third party project. The project is called cefobjc and has a cefobjchelper that is the same as cefsimple Helper (same code).

When I add libcef_dll_wrapper.a to the project, I get a linker error. I understand that my call to CefExecuteProcess is eventually using symbols that are not present in the project, but I don't understand why this project, that has both libcef_dll_wrapper.a and Chromium Embedded Framework.framework is missing those symbols. Can anybody please help me understand what's going on here?

Code: Select all
Ld /Users/pupeno/Library/Developer/Xcode/DerivedData/cefobjc-bxtruyemnyagwwgdejtzuxngovsr/Build/Products/Debug/cefobjchelper.app/Contents/MacOS/cefobjchelper normal x86_64
    cd /Users/pupeno/Projects/macninja-demos/cefobjc
    export MACOSX_DEPLOYMENT_TARGET=10.10
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/pupeno/Library/Developer/Xcode/DerivedData/cefobjc-bxtruyemnyagwwgdejtzuxngovsr/Build/Products/Debug -L/Users/pupeno/Projects/macninja-demos/cefobjc/CEF/Debug -F/Users/pupeno/Library/Developer/Xcode/DerivedData/cefobjc-bxtruyemnyagwwgdejtzuxngovsr/Build/Products/Debug -F/Users/pupeno/Downloads/cef_binary_3.2272.2029_macosx64/Debug -F/Users/pupeno/Projects/macninja-demos/cefobjc/CEF/Debug -filelist /Users/pupeno/Library/Developer/Xcode/DerivedData/cefobjc-bxtruyemnyagwwgdejtzuxngovsr/Build/Intermediates/cefobjc.build/Debug/cefobjchelper.build/Objects-normal/x86_64/cefobjchelper.LinkFileList -Xlinker -rpath -Xlinker @executable_path/../Frameworks -mmacosx-version-min=10.10 -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -lcef_dll_wrapper -framework Chromium\ Embedded\ Framework -Xlinker -dependency_info -Xlinker /Users/pupeno/Library/Developer/Xcode/DerivedData/cefobjc-bxtruyemnyagwwgdejtzuxngovsr/Build/Intermediates/cefobjc.build/Debug/cefobjchelper.build/Objects-normal/x86_64/cefobjchelper_dependency_info.dat -o /Users/pupeno/Library/Developer/Xcode/DerivedData/cefobjc-bxtruyemnyagwwgdejtzuxngovsr/Build/Products/Debug/cefobjchelper.app/Contents/MacOS/cefobjchelper

Undefined symbols for architecture x86_64:
  "std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::size() const", referenced from:
      cef::logging::operator<<(std::ostream&, wchar_t const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::string::c_str() const", referenced from:
      cef::logging::LogMessage::~LogMessage() in libcef_dll_wrapper.a(cef_logging.o)
  "std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::str() const", referenced from:
      cef::logging::LogMessage::~LogMessage() in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<int, int>(int const&, int const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned long, unsigned int>(unsigned long const&, unsigned int const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned int, unsigned long>(unsigned int const&, unsigned long const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<std::string, std::string>(std::string const&, std::string const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::allocator<char>::allocator()", referenced from:
      cef::logging::(anonymous namespace)::safe_strerror(int) in libcef_dll_wrapper.a(cef_logging.o)
  "std::allocator<char>::~allocator()", referenced from:
      cef::logging::(anonymous namespace)::safe_strerror(int) in libcef_dll_wrapper.a(cef_logging.o)
  "std::allocator<wchar_t>::allocator()", referenced from:
      cef::logging::operator<<(std::ostream&, wchar_t const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::allocator<wchar_t>::~allocator()", referenced from:
      cef::logging::operator<<(std::ostream&, wchar_t const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::basic_string(wchar_t const*, std::allocator<wchar_t> const&)", referenced from:
      cef::logging::operator<<(std::ostream&, wchar_t const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::~basic_string()", referenced from:
      cef::logging::operator<<(std::ostream&, wchar_t const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from:
      cef::logging::LogMessage::~LogMessage() in libcef_dll_wrapper.a(cef_logging.o)
  "std::ostream::operator<<(int)", referenced from:
      std::string* cef::logging::MakeCheckOpString<int, int>(int const&, int const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::ostream::operator<<(unsigned int)", referenced from:
      std::string* cef::logging::MakeCheckOpString<unsigned long, unsigned int>(unsigned long const&, unsigned int const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned int, unsigned long>(unsigned int const&, unsigned long const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::ostream::operator<<(unsigned long)", referenced from:
      std::string* cef::logging::MakeCheckOpString<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned long, unsigned int>(unsigned long const&, unsigned int const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned int, unsigned long>(unsigned int const&, unsigned long const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
      cef::logging::(anonymous namespace)::safe_strerror(int) in libcef_dll_wrapper.a(cef_logging.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:
      cef::logging::LogMessage::LogMessage(char const*, int, std::string*) in libcef_dll_wrapper.a(cef_logging.o)
      cef::logging::LogMessage::LogMessage(char const*, int, int, std::string*) in libcef_dll_wrapper.a(cef_logging.o)
      cef::logging::LogMessage::~LogMessage() in libcef_dll_wrapper.a(cef_logging.o)
      cef::logging::ErrnoLogMessage::~ErrnoLogMessage() in libcef_dll_wrapper.a(cef_logging.o)
  "std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)", referenced from:
      cef::logging::LogMessage::LogMessage(char const*, int, int) in libcef_dll_wrapper.a(cef_logging.o)
      cef::logging::LogMessage::LogMessage(char const*, int, std::string*) in libcef_dll_wrapper.a(cef_logging.o)
      cef::logging::LogMessage::LogMessage(char const*, int, int, std::string*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<int, int>(int const&, int const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned long, unsigned int>(unsigned long const&, unsigned int const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned int, unsigned long>(unsigned int const&, unsigned long const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      ...
  "std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()", referenced from:
      cef::logging::LogMessage::~LogMessage() in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<int, int>(int const&, int const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned long, unsigned int>(unsigned long const&, unsigned int const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<unsigned int, unsigned long>(unsigned int const&, unsigned long const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<std::string, std::string>(std::string const&, std::string const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
  "std::_Rb_tree_decrement(std::_Rb_tree_node_base*)", referenced from:
      std::_Rb_tree_iterator<std::pair<CefStringBase<CefStringTraitsUTF16> const, CefStringBase<CefStringTraitsUTF16> > >::operator--() in libcef_dll_wrapper.a(transfer_util.o)
  "std::_Rb_tree_increment(std::_Rb_tree_node_base const*)", referenced from:
      std::_Rb_tree_const_iterator<std::pair<CefStringBase<CefStringTraitsUTF16> const, CefStringBase<CefStringTraitsUTF16> > >::operator++() in libcef_dll_wrapper.a(transfer_util.o)
  "std::__throw_length_error(char const*)", referenced from:
      std::vector<CefStringBase<CefStringTraitsUTF16>, std::allocator<CefStringBase<CefStringTraitsUTF16> > >::_M_insert_aux(__gnu_cxx::__normal_iterator<CefStringBase<CefStringTraitsUTF16>*, std::vector<CefStringBase<CefStringTraitsUTF16>, std::allocator<CefStringBase<CefStringTraitsUTF16> > > >, CefStringBase<CefStringTraitsUTF16> const&) in libcef_dll_wrapper.a(transfer_util.o)
      std::vector<CefRefPtr<CefV8Value>, std::allocator<CefRefPtr<CefV8Value> > >::_M_insert_aux(__gnu_cxx::__normal_iterator<CefRefPtr<CefV8Value>*, std::vector<CefRefPtr<CefV8Value>, std::allocator<CefRefPtr<CefV8Value> > > >, CefRefPtr<CefV8Value> const&) in libcef_dll_wrapper.a(v8handler_cpptoc.o)
      std::vector<long long, std::allocator<long long> >::_M_insert_aux(__gnu_cxx::__normal_iterator<long long*, std::vector<long long, std::allocator<long long> > >, long long const&) in libcef_dll_wrapper.a(browser_ctocpp.o)
      std::vector<CefPageRange, std::allocator<CefPageRange> >::_M_insert_aux(__gnu_cxx::__normal_iterator<CefPageRange*, std::vector<CefPageRange, std::allocator<CefPageRange> > >, CefPageRange const&) in libcef_dll_wrapper.a(print_settings_ctocpp.o)
      std::vector<CefRect, std::allocator<CefRect> >::_M_insert_aux(__gnu_cxx::__normal_iterator<CefRect*, std::vector<CefRect, std::allocator<CefRect> > >, CefRect const&) in libcef_dll_wrapper.a(render_handler_cpptoc.o)
      std::vector<CefRefPtr<CefPostDataElement>, std::allocator<CefRefPtr<CefPostDataElement> > >::_M_insert_aux(__gnu_cxx::__normal_iterator<CefRefPtr<CefPostDataElement>*, std::vector<CefRefPtr<CefPostDataElement>, std::allocator<CefRefPtr<CefPostDataElement> > > >, CefRefPtr<CefPostDataElement> const&) in libcef_dll_wrapper.a(post_data_ctocpp.o)
  "std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)", referenced from:
      std::_Rb_tree<CefStringBase<CefStringTraitsUTF16>, std::pair<CefStringBase<CefStringTraitsUTF16> const, CefStringBase<CefStringTraitsUTF16> >, std::_Select1st<std::pair<CefStringBase<CefStringTraitsUTF16> const, CefStringBase<CefStringTraitsUTF16> > >, std::less<CefStringBase<CefStringTraitsUTF16> >, std::allocator<std::pair<CefStringBase<CefStringTraitsUTF16> const, CefStringBase<CefStringTraitsUTF16> > > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<CefStringBase<CefStringTraitsUTF16> const, CefStringBase<CefStringTraitsUTF16> > const&) in libcef_dll_wrapper.a(transfer_util.o)
  "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
      cef::logging::LogMessage::~LogMessage() in libcef_dll_wrapper.a(cef_logging.o)
  "std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
      CefExecuteProcess(CefMainArgs const&, CefRefPtr<CefApp>, void*) in libcef_dll_wrapper.a(libcef_dll_wrapper.o)
      CefInitialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, CefRefPtr<CefApp>, void*) in libcef_dll_wrapper.a(libcef_dll_wrapper.o)
      CefShutdown() in libcef_dll_wrapper.a(libcef_dll_wrapper.o)
      CefGetGeolocation(CefRefPtr<CefGetGeolocationCallback>) in libcef_dll_wrapper.a(libcef_dll_wrapper.o)
      CefAddCrossOriginWhitelistEntry(CefStringBase<CefStringTraitsUTF16> const&, CefStringBase<CefStringTraitsUTF16> const&, CefStringBase<CefStringTraitsUTF16> const&, bool) in libcef_dll_wrapper.a(libcef_dll_wrapper.o)
      CefRemoveCrossOriginWhitelistEntry(CefStringBase<CefStringTraitsUTF16> const&, CefStringBase<CefStringTraitsUTF16> const&, CefStringBase<CefStringTraitsUTF16> const&, bool) in libcef_dll_wrapper.a(libcef_dll_wrapper.o)
      CefLaunchProcess(CefRefPtr<CefCommandLine>) in libcef_dll_wrapper.a(libcef_dll_wrapper.o)
      ...
  "std::basic_ostream<char, std::char_traits<char> >& std::operator<<<char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      cef::logging::LogMessage::LogMessage(char const*, int, std::string*) in libcef_dll_wrapper.a(cef_logging.o)
      cef::logging::LogMessage::LogMessage(char const*, int, int, std::string*) in libcef_dll_wrapper.a(cef_logging.o)
      cef::logging::ErrnoLogMessage::~ErrnoLogMessage() in libcef_dll_wrapper.a(cef_logging.o)
      std::string* cef::logging::MakeCheckOpString<std::string, std::string>(std::string const&, std::string const&, char const*) in libcef_dll_wrapper.a(cef_logging.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
pupeno
Techie
 
Posts: 24
Joined: Wed Feb 25, 2015 7:48 am

Re: Linker error in MacOSX.

Postby magreenblatt » Fri Feb 27, 2015 11:59 am

Did you set up the correct architecture (either 32-bit or 64-bit)?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Linker error in MacOSX.

Postby pupeno » Fri Feb 27, 2015 12:48 pm

Hello magreenblatt,

Thanks for your answer. Yes, I believe I have the correct architecture. I built CEF as 64 bit:

Code: Select all
$ lipo -info CEF/Debug/libcef_dll_wrapper.a
input file CEF/Debug/libcef_dll_wrapper.a is not a fat file
Non-fat file: CEF/Debug/libcef_dll_wrapper.a is architecture: x86_64


and the project I'm using that library is also 64, I never changed and it's the default.
pupeno
Techie
 
Posts: 24
Joined: Wed Feb 25, 2015 7:48 am

Re: Linker error in MacOSX.

Postby magreenblatt » Fri Feb 27, 2015 1:02 pm

It looks like you might not be linking the C++ libraries. See http://stackoverflow.com/questions/6167 ... ols-on-osx.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Linker error in MacOSX.

Postby pupeno » Fri Feb 27, 2015 1:15 pm

Ah! That makes sense, since this is an Objectie-C project. I renamed main.m to main.mm so I could include include/cef_app.h in it, but I'm not sure which setting I need to change in the project to use a C++ compiler. My current settings look like this:

Image

I'm using Apple LLVM 6.0, which is the same one the cef project is using.

Do you know how do I change compilers in a Xcode 6.1 project?
pupeno
Techie
 
Posts: 24
Joined: Wed Feb 25, 2015 7:48 am

Re: Linker error in MacOSX.

Postby magreenblatt » Fri Feb 27, 2015 1:34 pm

There should be "C++ language Dialect" and "C++ standard library" settings somewhere. Try clicking the arrow next to "Compiler for C/C++/Objective-C"
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Linker error in MacOSX.

Postby pupeno » Fri Feb 27, 2015 1:39 pm

Switching from linking against libc++ to libstdc++ seems to have fixed the issue. I'm not 100% sure yet. Does this sound feasible?
pupeno
Techie
 
Posts: 24
Joined: Wed Feb 25, 2015 7:48 am

Re: Linker error in MacOSX.

Postby magreenblatt » Fri Feb 27, 2015 1:53 pm

pupeno wrote:Switching from linking against libc++ to libstdc++ seems to have fixed the issue. I'm not 100% sure yet. Does this sound feasible?

Both your application and libcef_dll_wrapper need to link the same one.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Linker error in MacOSX.

Postby pupeno » Fri Feb 27, 2015 3:03 pm

Should I compile libcef_dll_wrapper myself and copy it from CEF to my project? which one should I use, libc++ or libstdc++?
pupeno
Techie
 
Posts: 24
Joined: Wed Feb 25, 2015 7:48 am

Re: Linker error in MacOSX.

Postby magreenblatt » Fri Feb 27, 2015 3:49 pm

pupeno wrote:Should I compile libcef_dll_wrapper myself and copy it from CEF to my project? which one should I use, libc++ or libstdc++?

You always compile libcef_dll_wrapper yourself -- the source code is included with the binary distribution. Which library version to use depends on a number of factors including what OS X versions you plan to support and whether you need C++11 functionality. I would suggest googling libc++ vs libstdc++.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 84 guests