You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Call imwrite() on OS X error: Undefined symbols #6165
invalidquestion (invalid tracker)ask questions and other "no action" items here: https://forum.opencv.org
Undefined symbols for architecture x86_64:
"cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator > const&)", referenced from:
_main 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)
Undefined symbols for architecture x86_64:
"cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator > const&)", referenced from:
_main 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)
Actually, some other functions works well like imshow() etc..
31 is expected, so include files are good. -L/usr/local/lib compiler option is valid for provided build configuration.
What is about this command nm -g /usr/local/lib/libopencv_imgcodecs.dylib | grep imwrite?
And this: nm -g <path_to_main.o>/main.o | grep imwrite (you need to find main.o file, it is somewhere in opencv_getstarted.LinkFileList)
And this information: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -v
They are different.
This usually means, that there are different compilers (or compiler options, like -std=c++11) used to compile OpenCV library and to compile application.
I meet the exactly the same problem when I'm developing a node-webkit addon. But I don't know how to solve it ;-(. I compiled opencv with default llvm 7.3.0 and the addon with nw-gyp. Any idea? thank you so much
I tried the exact suggested approach and I still get a similar error:
Undefined symbols for architecture x86_64:
"cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)", referenced from:
parser::parser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) in ccO9dcvr.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
invalidquestion (invalid tracker)ask questions and other "no action" items here: https://forum.opencv.org
Activity
[-]Call imwrite() on OSX[/-][+]Call imwrite() on OS X error: Undefined symbols[/+]alalek commentedon Feb 25, 2016
Describe your steps with more details. Run
make VERBOSE=1or something else to show compiler/linker command line.everjesse commentedon Feb 25, 2016
Thank you for response!
I'm running a tutorial in the official docs in Xcode. The code shows like below.
And IDE gives me errors:
Actually, some other functions works well like imshow() etc..
alalek commentedon Feb 25, 2016
Thanks for update!
cv::imwriteshould be defined inopencv_imgcodecslibrary. Command line shows that this library is added to libraries list (three times).Could you try
std::cout << CV_VERSION_MAJOR << CV_VERSION_MINOR << std::endl;and add output?Could you try
std::cout << cv::getBuildInformation().c_str() << std::endl;and attach output?everjesse commentedon Feb 25, 2016
Below is the output of codes you mentioned before.
Thanks for your comment!
alalek commentedon Feb 25, 2016
31is expected, so include files are good.-L/usr/local/libcompiler option is valid for provided build configuration.What is about this command
nm -g /usr/local/lib/libopencv_imgcodecs.dylib | grep imwrite?And this:
nm -g <path_to_main.o>/main.o | grep imwrite(you need to find main.o file, it is somewhere inopencv_getstarted.LinkFileList)And this information:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -veverjesse commentedon Feb 25, 2016
Below is the command result.
nm -g /usr/local/lib/libopencv_imgcodecs.dylib | grep imwrite
nm -g main.o | grep imwrite
Thx!
alalek commentedon Feb 25, 2016
They are different.
This usually means, that there are different compilers (or compiler options, like
-std=c++11) used to compile OpenCV library and to compile application.Try to check compiler version at first:
And rebuild/reinstall OpenCV with current version of compiler.
everjesse commentedon Apr 25, 2016
Sorry for reply so late!
I've solved this question by rebuild/reinstall OpenCV library and choose the same C++ complier in Xcode with libc++.
Thank you for your patience and great help!!
iKeepWalking commentedon May 31, 2016
I meet the exactly the same problem when I'm developing a node-webkit addon. But I don't know how to solve it ;-(. I compiled opencv with default llvm 7.3.0 and the addon with nw-gyp. Any idea? thank you so much
dmsfabiano commentedon Mar 31, 2018
I tried the exact suggested approach and I still get a similar error:
I did the suggested check:
yields to:
and
outputs:
After that I did
brew reinstall opencvBut the error persists.
tanmayGIT commentedon May 13, 2018
Please have a look at : https://stackoverflow.com/a/50313990/3465857