I'm trying to use glfw 2.7.5 on my mac with xcode but I'm getting the following errors:
Undefined symbols for architecture i386:
"_glfwGetKey", referenced from:
Game::run() in Game.o
RedScene::update(float, bool) in main.o
"_glfwGetWindowParam", referenced from:
Game::run() in Game.o
"_glfwInit", referenced from:
Window::Window() in Window.o
"_glfwOpenWindow", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwOpenWindowHint", referenced from:
Window::Window() in Window.o
"_glfwPollEvents", referenced from:
Game::run() in Game.o
"_glfwSetKeyCallback", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwSetMouseButtonCallback", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwSetMousePosCallback", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwSetMouseWheelCallback", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwSetWindowTitle", referenced from:
Window::setCaption(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in Window.o
"_glfwSwapBuffers", referenced from:
RedScene::update(float, bool) in main.o
"_glfwSwapInterval", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwTerminate", referenced from:
Window::~Window() in Window.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've read this Problems using GLFW and XCode : won't compile and several other links on the internet but I can't find a solution.
I've set the Cocoa framework, the OpenGL framework and libglfw.a (which I compiled using "sudo make cocoa-install"), in the linker flags I set -lgflw and I'm building for 32-bit Intel. At first I was building for a 64-bit but I think GLFW doesn't support that on Mac yet (I was getting joystick file errors), the error changes when I compile for 32-bit and it can't find the functions I'm using. Any idea what I could do to fix this?
Most likely you have built libglfw.a for 64 bit and so you get link errors when you try to use it in a 32 bit app. You can either rebuild libglfw.a for 32 bit (or as a "fat" 32 bit and 64 bit library), or you could just build your app as 64 bit.
Note that in recent version of Mac OS X and Xcode, gcc builds 64 bit code by default, so you need to specify -m32 on the command line to get 32 bit code. How you do this in practice depends on the makefile for libglfw.a - there may well be an ARCH or other symbol that you can specify on the command line to force a 32 bit build.
Related
Subtitle: Undefined symbols for architecture x86_64: Building OpenCV and dlib with SCons on Mac OSX El Captain x86_64
I've been trying to make my app build in cross platform.
I have an SCons script that currently builds fine on windows, but it fails to build so in Mac.
I believe it is caused by some clashes with newer versions of XCode, because some of the previous versions of my code and scons worked nicely (before being refactored).
The following is the error message, and I believe it is quite common, but I seem to fail to find a way to remedy it.
In OpenCV2-highgui, cap_avfoundation.mm
Undefined symbols for architecture x86_64:
"_AVCaptureSessionPresetMedium", referenced from:
CvCaptureCAM::startCaptureDevice(int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVFileTypeAppleM4V", referenced from:
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVFileTypeMPEG4", referenced from:
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVFileTypeQuickTimeMovie", referenced from:
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVMediaTypeVideo", referenced from:
CvCaptureCAM::startCaptureDevice(int) in libOpencvHighgui.a(cap_avfoundation.o)
CvCaptureFile::CvCaptureFile(char const*) in libOpencvHighgui.a(cap_avfoundation.o)
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
...
...
...
In OpenCV2-highgui, window_cocoa.mm
"_OBJC_CLASS_$_NSSlider", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
"_OBJC_CLASS_$_NSString", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
objc-class-ref in libOpencvHighgui.a(cap_avfoundation.o)
"_OBJC_CLASS_$_NSTextField", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
"_OBJC_CLASS_$_NSThread", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
"_OBJC_CLASS_$_NSURL", referenced from:
...
...
...
In addition to building OpenCV, same error occurred in dlib_18_14, source.cpp
"_XAllocColor", referenced from:
void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libThirdPartyDlib_18_14.a(source.o)
"_XAllocSizeHints", referenced from:
dlib::base_window::set_size(int, int) in libThirdPartyDlib_18_14.a(source.o)
dlib::base_window::base_window(bool, bool) in libThirdPartyDlib_18_14.a(source.o)
dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libThirdPartyDlib_18_14.a(source.o)
"_XChangeProperty", referenced from:
dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libThirdPartyDlib_18_14.a(source.o)
"_XCheckIfEvent", referenced from:
dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libThirdPartyDlib_18_14.a(source.o)
"_XClearArea", referenced from:
dlib::base_window::invalidate_rectangle(dlib::rectangle const&) in libThirdPartyDlib_18_14.a(source.o)
"_XCloseDisplay", referenced from:
nativefont::font_renderer::font_renderer::vals_internal::~vals_internal() in libThirdPartyDlib_18_14.a(source.o)
dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libThirdPartyDlib_18_14.a(source.o)
"_XCloseIM", referenced from:
dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libThirdPartyDlib_18_14.a(source.o)
"_XConvertSelection", referenced from:
dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libThirdPartyDlib_18_14.a(source.o)
"_XCreateFontSet", referenced from:
dlib::base_window::base_window(bool, bool) in libThirdPartyDlib_18_14.a(source.o)
void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libThirdPartyDlib_18_14.a(source.o)
...
...
...
And the error is summed up as the following:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [out/darwin/x86_64/release/1.0.0/bin/libAPI3dfi_api_v1.dylib] Error 1
scons: building terminated because of errors.
I cannot expose the entire source code nor the scons build scripts here, so please mind that.
This is the sample snippet of how my scons script looks like to build a shared library (building static libraries are having no problems, just the shared libs):
Import('env')
# Add third party libraries
lib_env = env.Clone()
module_lib_env = lib_env.Clone()
target_os = env.get('TARGET_OS')
target_arch = env.get('TARGET_ARCH')
######################################################################
# Runtime Dependencies
######################################################################
pthread_path = env.get('PTHREAD_PATH') + '/lib'
intraface_path = env.get('INTRAFACE_PATH') + '/lib'
######################################################################
# General flags
######################################################################
module_lib_env.AppendUnique(CPPPATH = ['inc', 'src'])
######################################################################
# Libraries
######################################################################
module_lib_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')+'/bin',env.get('BUILD_DIR')+'/lib', pthread_path, intraface_path])
if target_os == 'windows':
module_lib_env.AppendUnique(LIBS = [
'libOpencvCore',
'libOpencvHighgui',
'libOpencvImgproc',
'libOpencvObjdetect',
'libOpencvFlann',
'libOpencvFeature2d',
'libOpencvVideo',
'libOpencvCalib3d',
'libOpencvMl',
'libFreeimage',
'libFreeimageOpenEXR',
'libFreeimageLibTIFF',
#'libFreeimageLibRawLite',
'libFreeimageLibPNG',
'libFreeimageLibOpenJPEG',
'libFreeimageLibJPEG',
'libFreeimageLibMNG',
'libFreeimageZLib',
'libThirdPartyDlib_18_14',
'pthread',
'IntraFaceDLL'])
else:
module_lib_env.AppendUnique(LIBS = [
'libOpencvCore',
'libOpencvHighgui',
'libOpencvImgproc',
'libOpencvObjdetect',
'libOpencvFlann',
'libOpencvFeature2d',
'libOpencvVideo',
'libOpencvCalib3d',
'libOpencvMl',
'libFreeimage',
'libFreeimageOpenEXR',
'libFreeimageLibTIFF',
#'libFreeimageLibRawLite',
'libFreeimageLibPNG',
'libFreeimageLibOpenJPEG',
'libFreeimageLibJPEG',
'libFreeimageLibMNG',
'libFreeimageZLib',
'libThirdPartyDlib_18_14',
'pthread'
# ,'IntraFaceDLL'
])
######################################################################
# Preprocessor flags
######################################################################
if not target_os == 'windows':
#allow error to be concidered as warning
module_lib_env.AppendUnique(CCFLAGS = ['-fpermissive'])
#disable warning
module_lib_env.AppendUnique(CCFLAGS = ['-Wno-sign-compare'])
module_lib_env.AppendUnique(CCFLAGS = ['-Wno-write-strings'])
module_lib_env.AppendUnique(CCFLAGS = ['-Wno-unused-variable'])
if target_os in ['darwin', 'ios']:
module_lib_env.AppendUnique(CPPDEFINES = ['_LIBCPP_HAS_NO_VARIADICS'])
######################################################################
# Source files and Targets
######################################################################
lib_src = env.Glob('src/*.cpp')
######################################################################
# Targets
######################################################################
module_lib_env.InstallTargetShared('libOpenCV', lib_src )
Here is the Full error log.
Here is how InstallTargetShared looks like:
def __install_shared(ienv, name, srcs):
ienv.SharedLibrary(target = os.path.join(env.get('BUILD_DIR') +'/bin/', name), source = srcs)
env.AppendUnique(TS = [name])
env.AddMethod(__install_shared, 'InstallTargetShared')
Any help or advices of what to do in this matter will be much appreciated!!
Looking at your full build log, I think you need to link against several OSX frameworks to resolve your issues. I don't see any in your linking command line:
g++ -o out/darwin/x86_64/release/1.0.0/bin/libAPI3dfi_api_v1.dylib -ldl -lpthread -mmacosx-version-min=10.11 -DWITH_OPENEXR=OFF -dynamiclib out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Api.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Manager.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Params.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Retry.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Device_Heartbeat.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Device_Init.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Frame_Stats.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Manager.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_Assign.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_End.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_Start.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/SHA1Hash.os -L/usr/local/lib -L/opt/local/lib -Ldeps/darwin/lib/x86_64 -Lout/darwin/x86_64/release/1.0.0 -L. -Lout/darwin/x86_64/release/1.0.0/bin -Lbin -Lout/darwin/x86_64/release/1.0.0/lib -Llib -L/Users/tllewellynn/Desktop/dev/build_scons/runtime/darwin/xcode/x86_64/pthread/lib -L/Users/tllewellynn/Desktop/dev/build_scons/runtime/darwin/xcode/x86_64/intraface/lib -lSDK3dfi_detect -lSDK3dfi_algo -lSDK3dfi_au -lSDK3dfi_align -lSDK3dfi_proc -lSDK3dfi_cluster -lSDK3dfi_attr -lSDK3dfi_type -lOpencvCore -lOpencvHighgui -lOpencvImgproc -lOpencvObjdetect -lOpencvFlann -lOpencvFeature2d -lOpencvVideo -lOpencvCalib3d -lOpencvMl -lFreeimage -lFreeimageOpenEXR -lFreeimageLibTIFF -lFreeimageLibPNG -lFreeimageLibOpenJPEG -lFreeimageLibJPEG -lFreeimageLibMNG -lFreeimageZLib -lFrameworkNvaam_base -lFrameworkNvaam_filter -lFrameworkNvaam -lFrameworkProtobuf -lFrameworkLibbff -lFrameworkNvclassifier -lFrameworkNvexpression -lFrameworkTrimesh2 -lFrameworkPolyfit -lFrameworkGClasses -lFrameworkFlandmark -lFrameworkAlglib -lNetMsgpack -lNetJsoncpp -lNetTinyxml2 -lNetTinyxmlparam -lCnnEblearnTools -lCnnEblearnIdx -lCnnEblearn -lThirdPartyDlib_18_14 -lSystemTinycthread -lSystemTinythread -lSystemGlobal -lSystemDebug -lpthread -lTbb -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/
Have you asked on any openCV forums or IRC channels?
Looks like you're missing several key frameworks from your link line.
I'm working with an external code in my project which I have access to the headers and the .cc files but I don't have any access to .dylibs. I'm getting some errors, related to link of the libs, that is described bellow.
This code runs perfectly well if I run it directly from the terminal. The problem only occured when I tried to incorporate it on my own project (that have other modules) in XCode. I guess that if I add the .dylib files to XCode it will solve the problem. However, I don't have the .dylibs. How can I put this code to run?
Undefined symbols for architecture x86_64:
"FACETRACKER::IO::LoadCon(char const*)", referenced from:
mark(int, char const**) in main.o
"FACETRACKER::IO::LoadTri(char const*)", referenced from:
mark(int, char const**) in main.o
"FACETRACKER::CLM::GetViewIdx()", referenced from:
mark(int, char const**) in main.o
"FACETRACKER::FDet::~FDet()", referenced from:
FACETRACKER::Tracker::~Tracker() in main.o
FACETRACKER::Tracker::Tracker(char const*) in main.o
"FACETRACKER::Tracker::Load(char const*)", referenced from:
FACETRACKER::Tracker::Tracker(char const*) in main.o
"FACETRACKER::Tracker::Track(cv::Mat, std::__1::vector<int, std::__1::allocator<int> >&, int, int, double, double, bool)", referenced from:
mark(int, char const**) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm trying to use some frameworks with Xcode 4.6.2.
C++ frameworks, such as cppunit and boost that is supposed to be compiled and linked to in my projects always fails with "Undefined symbols for architecture x86_64[...]" or i386 for that matter when I'm trying different build settings.
I have tried setting Compiler to clang and g++ with various sets of cpu-architecture flags (64, 32 and 32_64). I have come to a point where I can't find any solutions on my own.
I've also tried the fail safe packages from without any luck:
brew install cppunit universal
port install cppunit +universal
(Also without success the Boost library)
Also, a lot of tries on Boost is done. Bjam has really made a lot of work the last 24 hours. Multiple settings has been tried:
http://www.codeproject.com/Tips/555070/Boost-vs-OSX-iOS-XCode and
http://boost.2283326.n4.nabble.com/Errors-compiling-Boost-Log-on-OS-X-tp4646151p4646299.html
And more in pure trial and error on my part.
So my question is: what are the combination of compiler and linker and the respective flags I should use in order to make it work in my Xcode projects?
Per request from Captain Obvlious, here are some errors when running an application with Boost::Test:
Undefined symbols for architecture x86_64:
"boost::test_tools::tt_detail::check_impl(boost::test_tools::predicate_result const&, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, unsigned long, ...)", referenced from:
my_test::test_method() in main.o
"boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::basic_cstring<char const>, unsigned long, boost::unit_test::basic_cstring<char const>)", referenced from:
my_test::test_method() in main.o
"boost::unit_test::framework::master_test_suite()", referenced from:
init_unit_test_suite(int, char**) in main.o
"boost::unit_test::test_case::test_case(boost::unit_test::basic_cstring<char const>, boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&)", referenced from:
boost::unit_test::make_test_case(boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&, boost::unit_test::basic_cstring<char const>) in main.o
"boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, unsigned long)", referenced from:
___cxx_global_var_init2 in main.o
"boost::unit_test::ut_detail::normalize_test_case_name(boost::unit_test::basic_cstring<char const>)", referenced from:
boost::unit_test::make_test_case(boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&, boost::unit_test::basic_cstring<char const>) in main.o
"vtable for boost::unit_test::unit_test_log_t", referenced from:
boost::unit_test::unit_test_log_t::unit_test_log_t() in main.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You need to add whichever library those functions depend on via "Link Binary With Libraries" in the Build Phases of your Project. However, this then brings up the dreaded EXC_BAD_ACCESS you can read about elsewhere on Stack.
I'm trying to run some MPI programs in xcode 4. I installed openmpi from MacPort by typing sudo port install openmpi and the installation finished normally. Then I added opt/local/include/openmpi to my user header search paths, dragged the "libmpi.dylib" and "libmpi_cxx.dylib" into my project.
But then when I tried to run the program, I got the following error message:
Undefined symbols for architecture x86_64:
"_MPI_Comm_accept", referenced from:
MPI::Intracomm::Accept(char const*, MPI::Info const&, int) const in main.o
"_MPI_Comm_connect", referenced from:
MPI::Intracomm::Connect(char const*, MPI::Info const&, int) const in main.o
"_MPI_Comm_disconnect", referenced from:
MPI::Comm::Disconnect() in main.o
"_MPI_Comm_get_errhandler", referenced from:
MPI::Comm::Get_errhandler() const in main.o
"_MPI_Comm_set_errhandler", referenced from:
MPI::Comm::Set_errhandler(MPI::Errhandler const&) const in main.o
"_MPI_Comm_spawn", referenced from:
MPI::Intracomm::Spawn(char const*, char const**, int, MPI::Info const&, int) const in main.o
MPI::Intracomm::Spawn(char const*, char const**, int, MPI::Info const&, int, int*) const in main.o
"_MPI_Comm_spawn_multiple", referenced from:
MPI::Intracomm::Spawn_multiple(int, char const**, char const***, int const*, MPI::Info const*, int) in main.o
MPI::Intracomm::Spawn_multiple(int, char const**, char const***, int const*, MPI::Info const*, int, int*) in main.o
"_MPI_Grequest_complete", referenced from:
MPI::Grequest::Complete() in main.o
"_MPI_Op_commutative", referenced from:
MPI::Op::Is_commutative() const in main.o
"_MPI_Reduce_local", referenced from:
MPI::Op::Reduce_local(void const*, void*, int, MPI::Datatype const&) const in main.o
"_MPI_Win_call_errhandler", referenced from:
MPI::Win::Call_errhandler(int) const in main.o
"_MPI_Win_get_errhandler", referenced from:
MPI::Win::Get_errhandler() const in main.o
"_MPI_Win_set_errhandler", referenced from:
MPI::Win::Set_errhandler(MPI::Errhandler const&) const in main.o
"_ompi_mpi_comm_null", referenced from:
MPI::Intracomm::Intracomm(ompi_communicator_t*) in main.o
MPI::Graphcomm::Graphcomm(ompi_communicator_t* const&) in main.o
MPI::Cartcomm::Cartcomm(ompi_communicator_t* const&) in main.o
"_ompi_mpi_comm_world", referenced from:
_main in main.o
"_ompi_mpi_double", referenced from:
_main in main.o
"_ompi_mpi_op_sum", referenced from:
_main in main.o
"_ompi_op_set_cxx_callback", referenced from:
MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Am I missing anything in the above installation processes?
First be sure to have installed MPI.
I personally use brew to do so.
brew update
brew install open-mpi
Then check the requirements for c++:
mpic++ -showme
or mpicc -showme for c
My output with mpic++ is :
clang++ -I/usr/local/Cellar/open-mpi/1.8.6/include -L/usr/local/opt/libevent/lib -L/usr/local/Cellar/open-mpi/1.8.6/lib -lmpi_cxx -lmpi
Then we got the include path, library path and some other flags. From the output of the previous command we got that we need to add:
"/usr/local/Cellar/open-mpi/1.8.6/include" in the “Search Paths – Header Search Paths”
"/usr/local/opt/libevent/lib" and "/usr/local/Cellar/open-mpi/1.8.6/lib" in the “Search Paths – Library Search Paths”
"-lmpi_cxx -lmpi" in the “Linking – Other Linker Flags”
These can be done through the Build Settings option from the Xcode project.
Because mpi need to use it's own program to run ours we need to change the Executable.
Select "Edit schemes"
In the dialog box under Info for the Executable choose Other... from the combobox.
Change it to mpiexec wich is an alias of "orterun". For me it's in /usr/local/Cellar/open-mpi/1.8.6/bin. Note that this is usually an hidden folder. You can open it by pressing cmd + shift + g.
For running mpiexec need to know as arguments the number of processors and the executable file. So, in the same dialog box under Arguments
add "-n X" where X is the number of processors you want to use "for this example i will use 2".
add "$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH" wich is the combination of environment variables that specify the executable file.
Then add <mpi.h> header to your source code.
Run it and you will see 2 "Hello, World!" (because I use -n 2 for the example).
sources : open-mpi xcode FAQ, Debugging & running MPI programs in Xcode
I had the same problem, when I compiled openmpi from the sources, added header and library search paths, but forgot to add libraries as the linker flags to the build settings. Adding them solved this. You can type mpicc –showme to see the libraries that are necessary for mpi to run.
Or just type mpic++ instead of mpicc. That worked for me ;)
The example I'm trying to compile is from: http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/examples.html
(the chat example)
Here is what I'm using to make it:
>>> g++ chat_client.cpp chat_message.hpp
>>> g++ chat_server.cpp chat_message.hpp
This is what the terminal outputs:
% g++ chat_client.cpp chat_message.hpp
In file included from chat_client.cpp:17:
chat_message.hpp: In member function ‘void chat_message::encode_header()’:
chat_message.hpp:84: warning: format ‘%4d’ expects type ‘int’, but argument 3 has type ‘size_t’
ld: warning: in chat_message.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols:
"boost::system::generic_category()", referenced from:
__static_initialization_and_destruction_0(int, int)in cctJA2c1.o
__static_initialization_and_destruction_0(int, int)in cctJA2c1.o
"boost::thread::start_thread()", referenced from:
boost::thread::thread<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >(boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >, boost::disable_if<boost::is_convertible<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >&, boost::detail::thread_move_t<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > > >, boost::thread::dummy*>::type)in cctJA2c1.o
"boost::thread::join()", referenced from:
_main in cctJA2c1.o
"typeinfo for boost::detail::thread_data_base", referenced from:
typeinfo for boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >in cctJA2c1.o
"vtable for boost::detail::thread_data_base", referenced from:
boost::detail::thread_data_base::thread_data_base()in cctJA2c1.o
"boost::thread::~thread()", referenced from:
_main in cctJA2c1.o
_main in cctJA2c1.o
"boost::detail::thread_data_base::~thread_data_base()", referenced from:
boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::~thread_data()in cctJA2c1.o
boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::~thread_data()in cctJA2c1.o
"boost::system::system_category()", referenced from:
boost::system::get_system_category() in cctJA2c1.o
boost::system::error_code::error_code()in cctJA2c1.o
__static_initialization_and_destruction_0(int, int)in cctJA2c1.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Boost is installed correctly. I have another app that uses a couple of boosts bit features.
UPDATE:
this is the current command I'm using:
% g++ chat_client.cpp chat_message.hpp -lboost_asio -lboost_thread -o client -L/opt/local/lib/
says it can't find -lboost_asio
I looked in opt/local/lib (where boost is installed) and I don't see any libboost_asio.so or anything like that =\
You need to provide g++ boost libraries to link with usins -l option. I have a quick look on this examples and guess that you definitly need thread library. You can link with it using
g++ source.cpp -o executable -lboost_thread
Also you may need with boost_system library using
g++ source.cpp -o executable -lboost_thread -lboost_system