I have been fighting with an build error when using Features2D in OpenCV which i cannot figure out why.
OpenCV version: 2.4.3 (MacPorts)
Compile arch: 64-bit intel
C Language Dialect: GNU99
C++ Language Dialect: GNU++11
C++ Standard Library: libstdc++
The build error:
Undefined symbols for architecture x86_64:
"cv::FeatureDetector::detect(cv::Mat const&, std::__debug::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat const&) const", referenced from:
analysis::openCvStitching() in analysis.o
"cv::DescriptorMatcher::match(cv::Mat const&, cv::Mat const&, std::__debug::vector<cv::DMatch, std::allocator<cv::DMatch> >&, cv::Mat const&) const", referenced from:
analysis::openCvStitching() in analysis.o
"cv::DescriptorExtractor::compute(cv::Mat const&, std::__debug::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat&) const", referenced from:
analysis::openCvStitching() in analysis.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is how i create a pointer to the FeatureDetector and DescriptorExtractor:
Ptr<FeatureDetector> surfDetector = FeatureDetector::create(type);
Ptr<DescriptorExtractor> surfExtractor = DescriptorExtractor::create(type);
Have you tried deleting _GLIBCXX_DEBUG=1 and/or _GLIBCXX_DEBUG_PEDANTIC=1 from the preprocessor flags in your project settings? opencv2 c++ api is somewhat bad in its use of STL templates in the API functions, which may cause linker errors or crashes if your version of the standard libraries or compiler flags do not match exactly with what's used when it was compiled.
Related
so I've been trying to install OpenCV with C++ on my mac using this tutorial: https://medium.com/#jaskaranvirdi/setting-up-opencv-and-c-development-environment-in-xcode-b6027728003 but I keep getting this error on Xcode:
" 'opencv2/core.hpp' file not found "
I tried setting both Library Search Paths and Header Search Paths to recursive but it didn't change anything
I've also been getting this error on the terminal, I don't know if it's related. I think it's important to note that this isn't my first time trying to install opencv and I don't know if it's the old versions that keep messing with it. I tried to cleanup everything before installing this version but I'm not sure.
Undefined symbols for architecture x86_64:
"cv::namedWindow(cv::String const&, int)", referenced from:
_main in main-55ed98.o
"cv::String::deallocate()", referenced from:
cv::String::~String() in main-55ed98.o
cv::String::operator=(cv::String const&) in main-55ed98.o
"cv::String::allocate(unsigned long)", referenced from:
cv::String::String(char const*) in main-55ed98.o
"cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from:
_main in main-55ed98.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestions on how to solve these issues please?
For my application running on iPhone I am using OpenCV using opencv2.framework in Xcode with objective-c and C++ as languages. My development worked well until I wanted to introduce cv::Tracker that is not included in opencv2.framework but part of opencv_contrib.
I rebuilt and installed from the source opencv-3.4.0 with opencv_contrib-master using CMake and terminal commands make and install.
In Xcode I have set
HEADER_SEARCH_PATHS = /usr/local/include and
LIBRARY_SEARCH_PATHS = /usr/local/lib
When compiling I get a long list of errors of the style:
Undefined symbols for architecture x86_64:
"cv::error(int, cv::String const&, char const*, char const*, int)",
referenced from:
cv::Mat::Mat(int, int, int, void*, unsigned long) in OpenCVRenderer.o
"cv::Mat::operator=(cv::Scalar_<double> const&)", referenced from:
cv::Mat::Mat(int, int, int, cv::Scalar_<double> const&) in
OpenCVRenderer.o
cv::Mat::Mat(cv::Size_<int>, int, cv::Scalar_<double> const&) in
OpenCVRenderer.o
"cv::Mat::deallocate()", referenced from:
cv::Mat::release() in OpenCVRenderer.o
"cv::polylines(cv::_InputOutputArray const&, cv::_InputArray const&,
bool, cv::Scalar_<double> const&, int, int, int)", referenced from:
.
.
.
I set OTHER_LDFLAGS = (list of opencv dylibs) preceeded by a "-" sign
Now I get errors as if the libraries are not found while there are in fact in /usr/local/lib
For example I get:
ld: library not found for -libopencv_core.3.4.0.dylib
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
Any help?
Thank you.
There are a couples of problems with your settings.
You only specified where to find the libraries, not opencv2.framework. You should either specify framework_search_path (and link your framework to the project) or link the corresponding libraries.
You said you were building an iPhone app, yet the error says Undefined symbols for architecture x86_64:. That is, either you built your app for phone simulator or for mac. Yet, your framework is most likely built for iPhone architecture (armv7 and arm64). This case, you need to rebuild the framework. If you build iPhone app, do not link any dylib libraries in /usr/local/lib/.
Note that libopencv_core.3.4.0.dylib is part of normal opencv so the error has nothing to do with opencv_contrib (yet).
So I have been writing a c++ program and in it it handles integers too large for the inbuilt long long. No problem, I'll just use a bignum library. So I get GMP, utter those three magic commands "./configure, make, make install" and start using it. I use #include "gmpxx.h" as specified in the docs for a c++ program. Compiling it, GPP finds an error in gmpxx.h as apparently gmp.h can't be located using angles and quotes should be used instead in the include statement in gmpxx.h. Upon changing the angles to quotes, however, I am surprised to discover that something has gone wrong, I think with 'make'. It says:
Undefined symbols for architecture x86_64:
"___gmpz_clear", referenced from:
__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::~__gmp_expr() in primality-3fd487.o
"___gmpz_cmp_si", referenced from:
__gmp_binary_equal::eval(__mpz_struct const*, long) in primality-3fd487.o
"___gmpz_init", referenced from:
__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::__gmp_expr() in primality-3fd487.o
"___gmpz_set_d", referenced from:
__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::assign_d(double) in primality-3fd487.o
"___gmpz_tdiv_r_ui", referenced from:
__gmp_binary_modulus::eval(__mpz_struct*, __mpz_struct const*, long) in primality-3fd487.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anyone know how to stop either of these errors occurring?
I've managed to compile Swiften library for a iOS project, but now I'm having linking errors related to Boost library.
I've compiled Boost following these steps, the error I'm getting during linking is:
Undefined symbols for architecture arm64:
"vtable for boost::filesystem::detail::utf8_codecvt_facet", referenced from:
__GLOBAL__I_a in boost(path.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've read some articles which suggest including some compilation params, but not sure which params or where should I put them. I've also reached this thread with no solution. Anyone else faced this issue? Anyone succeeded compiling and running Swiften for iOS? Any tip on the right direction would be much appreciated.
UPDATE 1
It seems filesystem and program_options libs share utf8_codecvt_facet object, and one was overriding the other while building boost. Finally, I managed to compile the whole Swiften library, but when I try to use it I'm getting more linking errors :( I get this error when I declare a JID object on my main class:
Undefined symbols for architecture armv7:
"Swift::StringPrep::getPrepared(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&,
Swift::StringPrep::Profile)", referenced from:
Swift::JID::nameprepAndSetComponents(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > const&, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&) in JID.o
I have setup OpenCV2 in XCode but unfortunately imshow does not work:
Undefined symbols for architecture x86_64:
"cv::imshow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray 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)
I am running OS X 10.8.4 with latest XCode.
I have attached a few images below to show the setup in XCode and the libraries.
So far it seems that other functions work fine with OpenCV, except this.
I'm going to go out on a limb and say that you compiled OpenCV2 with libstdc++, and are now compiling your application with libc++ support.
You need to compile OpenCV2 with the same C++ library, otherwise it will not be able to link.
if you do an nm of the OpenCV2 library, if it was compiled with libstdc++, it will look like:
cv::imshow(std::string const&, cv::_InputArray const&)
while if it was compiled with libc++, it would look like:
cv::imshow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray const&)
to get the demangled symbol do:
nm library | c++filt | grep cv::imshow