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 2013-08-24 06:23:37 -0500

SreudianFlip gravatar image

updated 2013-08-26 02:03:36 -0500

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!

edit retag flag offensive close merge delete

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 ( 2013-08-26 02:17:42 -0500 )edit

3 answers

Sort by ยป oldest newest most voted
0

answered 2013-08-24 15:29:41 -0500

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} )
edit flag offensive delete link more

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

potatoprogrammer gravatar imagepotatoprogrammer ( 2014-09-08 01:51:59 -0500 )edit
0

answered 2013-10-06 14:25:50 -0500

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)

edit flag offensive delete link more
0

answered 2013-08-24 14:08:31 -0500

mviljamaa gravatar image
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-08-24 06:23:37 -0500

Seen: 2,411 times

Last updated: Oct 06 '13