I test the sample program by using BOOST C++ Library , On Compiling the sample Program shows following error log.
Sample Program : main.cpp
include <iostream>
include <boost thread="" thread.hpp="">
include <boost thread="" mutex.hpp="">
include <boost bind.hpp="">
boost::mutex io_mutex;
void count(int id) { for (int i = 0; i < 10; ++i) { boost::mutex::scoped_lock lock(io_mutex); std::cout << id << ": " << i << std::endl; } }
int main(int argc, char* argv[]) { boost::thread thrd1(boost::bind(&count, 1)); boost::thread thrd2(boost::bind(&count, 2)); thrd1.join(); thrd2.join(); return 0; }
Error Log:
CLEAN SUCCESSFUL (total time: 788ms) "/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf "/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/boosttest mkdir -p build/Debug/GNU-MacOSX rm -f "build/Debug/GNU-MacOSX/main.o.d" g++ -c -g -I/usr/local/include -I/usr/local/include/opencv -I/usr/local/include/opencv2 -I../boost-master -MMD -MP -MF "build/Debug/GNU-MacOSX/main.o.d" -o build/Debug/GNU-MacOSX/main.o main.cpp mkdir -p dist/Debug/GNU-MacOSX g++ -o dist/Debug/GNU-MacOSX/boosttest build/Debug/GNU-MacOSX/main.o -L/usr/local/lib -L../boost-master/libs /usr/local/lib/libopencv_calib3d.2.4.9.dylib /usr/local/lib/libopencv_calib3d.2.4.dylib /usr/local/lib/libopencv_calib3d.dylib /usr/local/lib/libopencv_contrib.2.4.9.dylib /usr/local/lib/libopencv_contrib.2.4.dylib /usr/local/lib/libopencv_contrib.dylib /usr/local/lib/libopencv_core.2.4.9.dylib /usr/local/lib/libopencv_core.2.4.dylib /usr/local/lib/libopencv_core.dylib /usr/local/lib/libopencv_features2d.2.4.9.dylib /usr/local/lib/libopencv_features2d.2.4.dylib /usr/local/lib/libopencv_features2d.dylib /usr/local/lib/libopencv_flann.2.4.9.dylib /usr/local/lib/libopencv_flann.2.4.dylib /usr/local/lib/libopencv_flann.dylib /usr/local/lib/libopencv_gpu.2.4.9.dylib /usr/local/lib/libopencv_gpu.2.4.dylib /usr/local/lib/libopencv_gpu.dylib /usr/local/lib/libopencv_highgui.2.4.9.dylib /usr/local/lib/libopencv_highgui.2.4.dylib /usr/local/lib/libopencv_highgui.dylib /usr/local/lib/libopencv_imgproc.2.4.9.dylib /usr/local/lib/libopencv_imgproc.2.4.dylib /usr/local/lib/libopencv_imgproc.dylib /usr/local/lib/libopencv_legacy.2.4.9.dylib /usr/local/lib/libopencv_legacy.2.4.dylib /usr/local/lib/libopencv_legacy.dylib /usr/local/lib/libopencv_ml.2.4.9.dylib /usr/local/lib/libopencv_ml.2.4.dylib /usr/local/lib/libopencv_ml.dylib /usr/local/lib/libopencv_nonfree.2.4.9.dylib /usr/local/lib/libopencv_nonfree.2.4.dylib /usr/local/lib/libopencv_nonfree.dylib /usr/local/lib/libopencv_objdetect.2.4.9.dylib /usr/local/lib/libopencv_objdetect.2.4.dylib /usr/local/lib/libopencv_objdetect.dylib /usr/local/lib/libopencv_ocl.2.4.9.dylib /usr/local/lib/libopencv_ocl.2.4.dylib /usr/local/lib/libopencv_ocl.dylib /usr/local/lib/libopencv_photo.2.4.9.dylib /usr/local/lib/libopencv_photo.2.4.dylib /usr/local/lib/libopencv_photo.dylib /usr/local/lib/libopencv_stitching.2.4.9.dylib /usr/local/lib/libopencv_stitching.2.4.dylib /usr/local/lib/libopencv_stitching.dylib /usr/local/lib/libopencv_superres.2.4.9.dylib /usr/local/lib/libopencv_superres.2.4.dylib /usr/local/lib/libopencv_superres.dylib /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.2.4.9.dylib /usr/local/lib/libopencv_video.2.4.dylib /usr/local/lib/libopencv_video.dylib /usr/local/lib/libopencv_videostab.2.4.9.dylib /usr/local/lib/libopencv_videostab.2.4.dylib /usr/local/lib/libopencv_videostab.dylib Undefined symbols for architecture x86_64: "boost::detail::thread_data_base::~thread_data_base()", referenced from: boost::detail::thread_data<boost::_bi::bind_t<void, void="" (*)(int),="" boost::_bi::list1<boost::_bi::value<int=""> > > >::~thread_data() in main.o "boost::system::system_category()", referenced from: ___cxx_global_var_init2 in main.o boost::thread_exception::thread_exception(int, char const) in main.o "boost::system::generic_category()", referenced from: ___cxx_global_var_init in main.o ___cxx_global_var_init1 in main.o "boost::thread::join_noexcept()", referenced from: boost::thread::join() in main.o "boost::thread::native_handle()", referenced from: boost::thread::get_id() const in main.o "boost::thread::start_thread_noexcept()", referenced from: boost::thread::start_thread() in main.o "boost::thread::detach()", referenced from: boost::thread::~thread() in main.o "typeinfo for boost::detail::thread_data_base", referenced from: typeinfo for boost::detail::thread_data<boost::_bi::bind_t<void, void="" (*)(int),="" boost::_bi::list1<boost::_bi::value<int=""> > > > in main.o "vtable for boost::detail::thread_data_base", referenced from: boost::detail::thread_data_base::thread_data_base() 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) make[2]: [dist/Debug/GNU-MacOSX/boosttest] Error 1 make[1]: [.build-conf] Error 2 make: ** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 8s)
Any One Can Suggest the Answer to me!