Question

I'm sorry to ask a question that resurfaces all over the place in different forms, but this has me tearing my hair out and I've tried every suggestion from all the dark corners of the internet.

I'm trying to use the Wt framework (for web based c++ applications) with Xcode. Its header files are at /usr/local/include and its library files (and boost's) are at /usr/local/lib. I can compile at the terminal with

gcc -o hello testWt.cpp -lstdc++ -lwt.3.3.0 -lwthttp.3.3.0 -lboost_random -lboost_regex -lboost_signals -lboost_system -lboost_thread -lboost_filesystem -lboost_program_options -lboost_date_time

but within Xcode I've had no luck. I've tried:

  • Adding -I/usr/local/include to the OTHER_C++_FLAGS option
  • Adding /usr/local/lib to the Library Search Paths option
  • Adding /usr/local/include to Header Search Paths
  • Dragging all the libraries (both the .dylib and/or the .a versions) into the "Link Binary with Libraries" section
  • All combinations of the above

Now, I'm bashing my head against this linker error:

Ld /Users/charles/Library/Developer/Xcode/DerivedData/Test-dzrqjofmpnjowvcwtscacpwnhtqw/Build/Products/Debug/Test normal x86_64
cd /Users/charles/tmp/Test
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/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.8.sdk -L/Users/charles/Library/Developer/Xcode/DerivedData/Test-dzrqjofmpnjowvcwtscacpwnhtqw/Build/Products/Debug -L/usr/local/lib -F/Users/charles/Library/Developer/Xcode/DerivedData/Test-dzrqjofmpnjowvcwtscacpwnhtqw/Build/Products/Debug -filelist /Users/charles/Library/Developer/Xcode/DerivedData/Test-dzrqjofmpnjowvcwtscacpwnhtqw/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/Test.LinkFileList -mmacosx-version-min=10.7 -stdlib=libc++ -lwt.3.3.0 -lwthttp.3.3.0 -lboost_atomic -lboost_chrono -lboost_context -lboost_date_time -lboost_exception -lboost_filesystem -lboost_graph -lboost_iostreams -lboost_locale -lboost_math_c99 -lboost_math_c99f -lboost_math_c99l -lboost_math_tr1 -lboost_math_tr1f -lboost_math_tr1l -lboost_prg_exec_monitor -lboost_program_options -lboost_python -lboost_random -lboost_regex -lboost_serialization -lboost_signals -lboost_system -lboost_test_exec_monitor -lboost_thread -lboost_timer -lboost_unit_test_framework -lboost_wave -lboost_wserialization -o /Users/charles/Library/Developer/Xcode/DerivedData/Test-dzrqjofmpnjowvcwtscacpwnhtqw/Build/Products/Debug/Test

Undefined symbols for architecture x86_64:

  "Wt::WApplication::makeAbsoluteUrl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
  vtable for HelloApplication in main.o

ld: symbol(s) not found for architecture x86_64

Further than this I cannot get. This is the first time I've used Xcode for development so I may be missing something obvious; I'd be incredibly grateful if someone could point it out!

Était-ce utile?

La solution

OK I finally got it. It turns out that the problem was that my program is written using the libc++ libraries whereas the Wt library was built using the older libstdc++.

To fix this, I recompiled boost and Wt using libc++ instead by changing their CMakeLists.txt file, adding the line set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++"). This produced a tonne of warnings, but seemed to work.

After installing these new builds, I made sure that Xcode had -L/usr/local/lib -I/usr/local/include in its Other C++ Flags options and /usr/local/include & /usr/local/lib in 'Header Search Paths' and 'Library Search Paths' respectively. Then, I added the libraries into the "Link Binaries with Library" section. This solved my problem.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top