Ask Your Question
0

After installing OpenCV 2.9.0.0, I can't compile any program, g++ gives errors (e.g g++: error: pthread: No such file or directory). Please help!

asked Aug 24 '13

SreudianFlip gravatar image

updated Aug 26 '13

After cloning the source, I followed the instructions on the website to the letter, but on compiling any of the programs that worked fine with OpenCV 2.4.5 with this command:

g++ -ggdb 'pkg-config --cflags opencv' main.cpp 'pkg-config --libs opencv'

, I receive this:

g++: error: rt: No such file or directory
g++: error: pthread: No such file or directory
g++: error: m: No such file or directory
g++: error: dl: No such file or directory

Please help, I'm a beginner here and I really need the intersection and chi^2 kernels for SVMS that aren't in the previous version. If there's any way to use those in the older version, I'd be grateful. Thanks!

Preview: (hide)

Comments

Small remark. We suggest not to use hashtags in the tags of your topic. They generate a lot of double tags, rendering the search and filter options useless. Keep this in mind at your next post, adjusted it for you now.

StevenPuttemans gravatar imageStevenPuttemans (Aug 26 '13)edit

3 answers

Sort by » oldest newest most voted
0

answered Aug 24 '13

berak gravatar image

since you're trying to work with the master version, maybe it's a good idea to generate your makefile / proj with cmake in the same way you built the libraries before.

this will saving you the trouble of manually adjusting changed linker settings, include paths, etc.

whenever something changes(and things change fast!), you woud just run cmake again.

a simple CmakeLists.txt file will do:

cmake_minimum_required (VERSION 2.6) 

FIND_PACKAGE( OpenCV REQUIRED )

PROJECT(MyProject) # change this! (project_name)
SET(SRC
    main.cpp       # change this! (src files)
)
ADD_EXECUTABLE( ${PROJECT_NAME} ${SRC} )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME}  ${OpenCV_LIBS} )
Preview: (hide)

Comments

Just for clarification, for the field "${OpenCV_LIBS}", would I put in the path to where I have the opencv library installed (ex. /usr/local/include)?

0

answered Oct 6 '13

Can you take a look at [source_dir]/release/unix-install/opencv.pc ?

When I call cmake on my machine, the .pc file is generated badly - the Libs: field ends with: rt pthread m dl, presumably it should end with -lrt -lpthread -lm -ldl.

Building any opencv projects with pkg-config, I got the same error that you do, and the error is fixed by making the appropriate change to opencv.pc.

(NB - of course pkg-config doesn't look in [source_dir]/build/unix-install for opencv.pc. If you want to do a quick test of changing the .pc file and recompiling your application, make sure you're editing the opencv.pc in /usr/lib/pkgconfig or /usr/local/lib/pkgconfig)

Preview: (hide)
0

answered Aug 24 '13

mviljamaa gravatar image
Preview: (hide)

Question Tools

Stats

Asked: Aug 24 '13

Seen: 3,123 times

Last updated: Oct 06 '13