nyanp / mnisten

convert image files to mnist idx format
61 stars 30 forks source link

build error: symbol(s) not found for architecture x86_64 #14

Open JohannesHeidecke opened 7 years ago

JohannesHeidecke commented 7 years ago

Hey everyone,

I am trying to build mnisten with macOS 10.12 and can't get the following error to disappear:

ld: symbol(s) not found for architecture x86_64

amongst others it's complaining about

Undefined symbols for architecture x86_64: "cv::_InputArray::_InputArray(cv::Mat const&)", referenced from: read_images(boost::filesystem::path const&, unsigned char, std::__1::vector<image, std::__1::allocator<image> >&, int, int) in main-526ee7.o … … "boost::filesystem::detail::dir_itr_close(void*&, void*&)", referenced from: boost::detail::shared_count::shared_count<boost::filesystem::detail::dir_itr_imp>(boost::filesystem::detail::dir_itr_imp*) in main-526ee7.o boost::detail::sp_counted_impl_p<boost::filesystem::detail::dir_itr_imp>::dispose() in main-526ee7.o … … "boost::system::system_category()", referenced from: __GLOBAL__sub_I_main.cpp in main-526ee7.o

I am not very familiar with makefiles, after trying a couple of dozen stackoverflow threads, I thought I might just ask here. Please let me know which information about my setup you need to help me out!

Any ideas how to fix this? Has someone run this successfully on macOS 10.12?

Thanks!

vip7265 commented 7 years ago

'Makefile' seems to have some errors. That situation happens to me but I ran on Linux.

I fixed the problem by modifying 'Makefile' as,

g++ -Wall -O2 -lboost_system -lboost_filesystem -std=c++0x -o mnisten src/main.cpp

You should add -lboost_system for -lboost_filesystem because those symbols are in the boost_system library.

JohannesHeidecke commented 7 years ago

@BaeInpyo thanks for your help!

this seems to have resolved at least some errors, however some remain still around the ld: symbol(s) not found for architecture x86_64 message.

Undefined symbols for architecture x86_64: "cv::_InputArray::_InputArray(cv::Mat const&)", referenced from: read_images(boost::filesystem::path const&, unsigned char, std::__1::vector<image, std::__1::allocator<image> >&, int, int) in main-7d351f.o ... "boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&)", referenced from: read_images(boost::filesystem::path const&, unsigned char, std::__1::vector<image, std::__1::allocator<image> >&, int, int) in main-7d351f.o ... ld: symbol(s) not found for architecture x86_64

Maybe you have some idea, I'm not that familiar with build processes.

YilinLiu97 commented 7 years ago

I'm having the same error here. Have you resolved it?

chiunti commented 7 years ago

Try changing makefile as below:

mnisten: src/main.cpp g++ -Wall -O2 -std=c++0x -o mnisten src/main.cpp -lboost_system -lboost_filesystem -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_imgcodecs