I'm trying to configure my Netbeans to use OpenCV 3.0.0,
When I try to build my project I got this message:
undefined reference to `cv::putText(cv::InputOutputArray const&, cv::String const&, cv::Point, int, double, cv::Scalar_, int, int, bool)'
These are my includes:
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
and my linker config:
additional libraries ---> C:/OpenCV/release/lib
libraries ---> C:/OpenCV/release/lib/libopencv_core300.dll.a ,
C:/OpenCV/release/lib/libopencv_highgui300.dll.a
Netbeans version 8.0.2, OpenCV version 3.0.0
I've compiled my own OpenCV with cmake-gui ( mingw ).
Related
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).
I have installed dlib using Homebrew.
brew install dlib
How can I create a C++ project that uses dlib in Xcode ? I have tried some build settings. However, it does not work.
Add /usr/local/Cellar/dlib/19.1_2/include to Header Search Paths
Add /usr/local/Cellar/dlib/19.1_2/lib to Library Search Paths
Add -ldlib to Other Linker Flags
I have got these errors:
Undefined symbols for architecture x86_64:
"_cblas_dgemm", referenced from:
dlib::blas_bindings::cblas_gemm(dlib::blas_bindings::CBLAS_ORDER, dlib::blas_bindings::CBLAS_TRANSPOSE, dlib::blas_bindings::CBLAS_TRANSPOSE, int, int, int, double, double const*, int, double const*, int, double, double*, int) in main.o
"_cblas_saxpy", referenced from:
dlib::blas_bindings::cblas_axpy(int, float, float const*, int, float*, int) in main.o
"_cblas_sscal", referenced from:
dlib::blas_bindings::cblas_scal(int, float, float*) in main.o
"_dgesvd_", referenced from:
dlib::lapack::binding::gesvd(char, char, int, int, double*, int, double*, double*, int, double*, int, double*, int) 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)
By default, homebrew installs dlib without any BLAS library. I have solved the issue by linking Accelerate.framework with binary file.
Accelarate.framework is provided by Apple. It includes everything that dlib needs. Further information:
https://developer.apple.com/reference/accelerate
In order to add that library to your project,
Choose the project name in project navigator (Left Side).
If it is not appeared on the editor, click "Show project and targets list" and choose target binary.
Choose "Build Phases" shown below.
Expand "Link Binary With Libraries" and click add items icon.
Search Accelerate.framework and add it.
Change its status to "Required".
Alternatively, it may work if you uninstall dlib and install dlib with brew install dlib --with-openblas command. However, I haven't tested it yet.
By the way, Homebrew warns about openblas if you brew info openblas:
macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
brew cask install xquartz
brew install gtk+3 boost
brew install dlib
Then your setup will be fine. I am using without adding Accelerate.framework explicitly.
Little new to OpenCV, i've made some stuff in Java OpenCV, but limited with this lib, i've step to C/C++ with much difficulties!
I've succeded building and running C OpenCV projects, but seeing most of tutorials running on C++ version, i'm trying to make a simple "HelloCV":
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
Mat img = imread("c:/lenna.png", CV_LOAD_IMAGE_COLOR);
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
imshow("MyWindow", img);
waitKey(0);
return 0;
}
I always get the following errors :
../src/mainCPP.cpp:12: undefined reference to `cv::imread(std::string const&, int)'
../src/mainCPP.cpp:14: undefined reference to `cv::namedWindow(std::string const&, int)'
../src/mainCPP.cpp:15: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
../src/mainCPP.cpp:15: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
../src/mainCPP.cpp:17: undefined reference to `cv::waitKey(int)'
src\maincpp.o: In function `ZN2cv3MatD1Ev':
C:/OpenCV_2.4.9/opencv/build/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'
src\maincpp.o: In function `ZN2cv3Mat7releaseEv':
C:/OpenCV_2.4.9/opencv/build/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'
collect2.exe: error: ld returned 1 exit status
I've followed about 4-5 installations tuto, but I only succed in crashing my projects!
My "working" settings :
C/C++ Build -> GCC C++ Compiler -> Includes -> Include paths (-I) : path to my include folder ( "C:\OpenCV_2.4.9\opencv\build\include" )
C/C++ Build -> GCC C++ Linker -> Libraries -> Library search path (-L) -> "C:\OpenCV_2.4.9\opencv\build\x86\vc11\lib",
I know I've put the path to the x86 instead of x64 due to lib error like : "Not compatible system architecture"...!
C/C++ Build -> GCC C++ Linker -> Libraries -> Libraries (-l) : opencv_core249, opencv_imgproc249 and highgui249 (i've tested including all libs but it's the same)
I've added the environment variable : C:\OpenCV_2.4.9\opencv\build\x86\vc11\bin (isn't it only for M$ Visual Studio?!)
Seems like openCV isn't getting installed properly. Try using Chocolatey, it can cleanly install the latest version of OpenCV on windows.
I am trying to static link OpenCV libraries on Windows. I already built the library with BUILD_SHARED_LIBS OFF and I created a project on the Eclipse (am using MinGW by the way). C:\opencv is set as my source while C:\opencv\build\x86\mingw is set as the destination on the cmake-gui. I then executed mingw32-make and mingw32-make install on C:\opencv\build\x86\mingw.
My question is, how do I static link those libraries on the Eclipse, I tried several ways but my OpenCV application still doesn't work on computers without OpenCV installed.
Here's what I tried so far, I set
C:\opencv\build\x86\mingw\install\include as the include folder;
C:\opencv\build\x86\mingw\lib as the library path on the "Linker" and I have opencv_core246, opencv_highgui246, opencv_objdetect246 and opencv_imgproc246.
This way it seems like it still uses "dynamic linking" so I tried adding -static on the Miscellaneous option but then I got these errors:
C:\opencv\build\x86\mingw\lib\libopencv_imgproc246.a(templmatch.cpp.obj):templmatch.cpp:
(.text$_ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x1ce5):
undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
C:\opencv\build\x86\mingw\lib\libopencv_imgproc246.a(templmatch.cpp.obj):templmatch.cpp:
(.text$_ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x1dab):
undefined reference to `cv::mulSpectrums(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, bool)'
C:\opencv\build\x86\mingw\lib\libopencv_imgproc246.a(templmatch.cpp.obj):templmatch.cpp:
(.text$_ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x1ded):
undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
collect2: ld returned 1 exit status
Anyone can provide me real step-by-step to static link OpenCV library on Windows using Eclipse and MinGW?
EDIT: I found out that in VS we have to add libraries such as: libtiff.lib libpng.lib libjpeg.lib libjasper.lib IlmImf.lib zlib.lib to the Linker which I did but the problem persists. Then I heard adding Vfw32.Lib comctl32.lib solved the problem but unfortunately I guess they are VS-specific.
Adding 3rd party libraries -llibjasper -llibtiff -lopencv_lapack -lzlib -lpng -ljpeg -lpthread -lrt should solve the issue.
Try compiling a very basic OpenCV code. The order of the libraries that are linked is important while linking static libraries.
If libraryA is depend on libraryB, then libraryA must be defined before defining libraryB.
I just wrote a little program using the boost filesystem library. Now it comes with some weird linking errors.
I already tried reordering the libraries, checked compiler version used for the boost binaries (Boost 1.51.0; MinGW 4.7.1 static libraries) and my MinGW version - 4.7.1.
Has someone an idea what else the cause for this could be?
Thanks in advance.
The output of the linker was:
obj\Debug\main.o: In function `ZN5boost10filesystem6existsERKNS0_4pathE':
C:/boost_1_51_0/boost/filesystem/operations.hpp:289: undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
obj\Debug\main.o: In function `ZN5boost10filesystem4pathC1IA15_cEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE':
C:/boost_1_51_0/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()'
obj\Debug\main.o: In function `ZN5boost10filesystem11path_traits8dispatchISbIwSt11char_traitsIwESaIwEEEEvRKSsRT_RKSt7codecvtIwciE':
C:/boost_1_51_0/boost/filesystem/path_traits.hpp:174: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string, std::allocator >&, std::codecvt const&)'
I linked to the following libraries (set in Code::Blocks build options):
...\boost_1_51_0\stage\lib\libboost_system-mgw47-mt-d-1_51.a
...\boost_1_51_0\stage\lib\libboost_filesystem-mgw47-mt-d-1_51.a
The source Code (the interesting parts, i.e. the parts using boost):
//...
#define BOOST_SYSTEM_NO_DEPRECATED
#define BOOST_FILESYSTEM_NO_DEPRECATED
#include <boost/filesystem.hpp>
//...
int main()
{
boost::filesystem::path p("./file.txt");
if(boost::filesystem::exists(p)) cout
//...
}
//...