Hello. I am having trouble with building the libraries for my Juce audio plugin (I am using MacOSX/xcode). I am attempting to use OpenCV in my project, and need to include three OpenCV libraries in my Juce project. Below is what I currently have as input to each category in the introjucer.
Extra Linker Flags: -lopencv_core -lopencv_highgui -lopencv_imgproc
Header Search Paths: /usr/local/include
Extra Library Search Paths: /usr/local/lib
Both of the search paths are set for the Release and the Debug builds. My c++ code has the following line: #include <opencv2/core/core.hpp> . This produces an error saying 'opencv2/core/core.hpp' file not found.
I have tried many different configurations without success (including changing the #include statement to things such as #include <opencv2/core.hpp> and #include <core.hpp> in an attempt to see if that was the issue).
Iâve just tried including the OpenCV headers but I didnât run into the same problems as you. The steps I took were:
Installed OpenCV using homebrew (homebrew-science)
Added /usr/local/include to header search paths
Saved project and opened in IDE (Xcode)
Did â#include <opencv2/core/core.hpp>â in PluginProcessor.h of the audio plug-in demo
Iâm using the latest version of the Projucer on the develop branch and this compiled without problems. I realise this doesnât give you much help, but Iâm not sure whatâs going wrong. If you could follow exactly the same procedure and it works then we could perhaps deduce itâs something going wrong with your specific project, rather than a more general problem.
Thank you for your help! I was attempting to include the headers in the PluginEditor.cpp file. After deleting those lines and adding them instead to the PluginProcessor.h file, it works fine. I assume this was in the end a problem of me not fully understanding c++ rather than a real problem with my Juce configurations.
So now it will compile fine with the include statements, but it errors whenever I attempt to use anything from the opencv libraries. For example, even declaring a new Mat with Mat edges; gives me the following error:
Undefined symbols for architecture x86_64:
"cv::Mat::deallocate()", referenced from:
cv::Mat::release() in libNewProject.a(PluginEditor.o)
"cv::fastFree(void*)", referenced from:
cv::Mat::~Mat() in libNewProject.a(PluginEditor.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 opencv code I attempt to run gives me a similar series of errors, all saying that the symbols are undefined for x86_64. Any suggestions?
That looks like youâre not linking the OpenCV libraries correctly. Try compiling a very simple test program which uses a Mat from the command line and experiment with which libraries you need. The command will look similar to
Using the exact command you wrote, a simple program using opencv libraries to make a Mat works fine. Is there something in AppConfig.h or JuceHeader.h or something like that that I need to add in order to properly link the opencv libraries?
This should be configurable from the Projucer. Try putting
opencv_core
opencv_highgui
opencv_imgproc
in âExternal libraries to linkâ instead of what you have in âExtra linker flagsâ. Then, if that still fails, could you paste the link line from Xcode? You can find this by looking at all messages from the build log and it should be highlighted in red.