lundi 30 mars 2015

opencv linking error macosx 'undefined reference for architecture'

I am currently trying to compile a working camera calibration using g++4.9 and OpenCV 3.0 beta.


The Problem is I am getting some strange linking errors although I have linked everything like I linked it on my Ubuntu Machine.


This is the makefile I am using at the moment: CC=g++-4.9 CFLAGS=-c -g -fPIC -Wall -std=c++11 -fdiagnostics-color=auto



SRC=fisheye.cpp
OBJ=fisheye.o
PROG=fisheye

INC_PATH=-I/usr/local/include/opencv2/
LIB_PATH=-L/usr/local/lib/
LIBS= -lopencv_core \
-lopencv_highgui \
-lopencv_calib3d \
-lopencv_features2d \
-lopencv_imgproc

all: $(OBJ)
@$(CC) $(CFLAGS) $(INC_PATH) $(SRC) -o $(OBJ)
@echo 'Compiled fisheye.cpp successfully'
@$(CC) $(OBJ) -o $(PROG) $(LIB_PATH) $(LIBS)
@echo 'Linking complete'

clean:
rm -rf $(OBJ) $(PROG)


Which is just returning stuff like:



Compiled fisheye.cpp successfully
Undefined symbols for architecture x86_64:
"cv::imread(cv::String const&, int)", referenced from:
_main in fisheye.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [all] Error 1


I built OpenCV manually using cmake and make and the directories are right. Compiling works the main Problem is the linking process.


If I compile and link using the following commands(where g++11 is an alias for g++-4.9 -std=c++11 -fdiagnostics-color=auto it fails with the same error:



//compiling:
g++11 -c -g -Wall -I/usr/local/include/opencv2/ fisheye.cpp

//linking:
g++11 -o fisheye fisheye.o -L/usr/local/lib/ -lopencv_core -lopencv_highgui -lopencv_calib3d -lopencv_imgproc -lopencv_features2d


I also took a look to similar topic on stack overflow but none of them fixed my problem.


Maybe anyone of you has an idea.


Aucun commentaire:

Enregistrer un commentaire