pkg-config file for 3.0.0 beta incomplete?
Hello,
I am currently switching from OpenCV 2.4.9 to 3.0.0 beta on my 64-bit Ubuntu 14.04 system. I built OpenCV from source, installed it and tried to link against it using a Makefile that worked fine with OpenCV 2.4.9. It basically looks like this:
CXX ?= g++
CXXFLAGS += -c -Wall `pkg-config --cflags opencv`
LDFLAGS += -static `pkg-config --libs --static opencv`
all: test.exe
test.exe: test.o
$(CXX) $< -o $@ $(LDFLAGS)
%.o: %.cpp
$(CXX) $< -o $@ $(CXXFLAGS)
clean:
rm -f test.o test.exe
I am using the following minimal example source file (test.cpp):
#include <iostream>
#include "opencv2/core/core.hpp"
using namespace std;
using namespace cv;
int main(const int argc, const char * const argv[])
{
cout << getBuildInformation() << endl;
return 0;
}
Linking fails due to several unresolved references. Although it was not hard to figure out that I had to add -lpthread -lz -ldl
to LDFLAGS
, it seemed strange to me that pkg-config did not do that already. When I looked at the .pc file of OpenCV in the pkg-config directory, I noticed that no other libraries than the OpenCV libraries themselves were listed there. In version 2.4.9., the pkg-config file included -lphread -lz -ldl and many other in its "Libs:" line, but 3.0.0 does not do so any longer.
What is the reason for this? Is the pkg-config file incomplete on purpose or is this an artifact of the beta version? If so, is there any way to get a complete pkg-config file like in 2.4.9 before the final release?
Best regards Andreas
Okay have a look at the transition guide! You need to make some adaptations to your code, in your case switch
#include "opencv2/core/core.hpp"
towards#include "opencv2/core.hpp"
. All headers have been moved up!@StevenPuttemans: Thanks for the hint, but this does not solve the problem with the linker errors, unfortunately, since the pkg-config file is still incomplete.
This is known issue, the fix should be similar to this pull request. I'd recommend you to use cmake version if possible, since it is tested on buildbot. (The sample project is already integrated).
Also, note that there already exists pull request with a lot of modifications to
OpenCVGenPkgconfig.cmake
(in case if you are going to prepare your own fix).Unfortunately, I cannot use cmake in my use case. Would it make send to file a bug report by reporting this issue?
I've created it here, you can add any details if you want.
@mshabunin: Thank you very much. There is nothing to add at the moment (since you provided the link to this question with the examples), but I'll provide any necessary information if required.