pkg-config file for 3.0.0 beta incomplete?

asked 2015-04-21 07:38:43 -0500

dustsigns gravatar image

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 -ldlto 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

edit retag flag offensive close merge delete

Comments

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 gravatar imageStevenPuttemans ( 2015-04-21 08:13:48 -0500 )edit
1

@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.

dustsigns gravatar imagedustsigns ( 2015-04-21 08:18:33 -0500 )edit
1

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).

mshabunin gravatar imagemshabunin ( 2015-04-21 10:31:40 -0500 )edit
1

Unfortunately, I cannot use cmake in my use case. Would it make send to file a bug report by reporting this issue?

dustsigns gravatar imagedustsigns ( 2015-04-22 01:59:34 -0500 )edit

I've created it here, you can add any details if you want.

mshabunin gravatar imagemshabunin ( 2015-04-22 03:33:05 -0500 )edit

@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.

dustsigns gravatar imagedustsigns ( 2015-04-22 04:43:26 -0500 )edit