Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
678 views
in Technique[技术] by (71.8m points)

opencv - About Makefile can't find libraries

The Exception is here:

g++ -L/usr/local/lib -I./include -I. -lopencv_core -lopencv_highgui -lopencv_imgproc main.o ColorTransfer.o
main.o: In function `showImg(std::string, cv::Mat, int)':
main.cpp:(.text+0x21): undefined reference to `cv::namedWindow(std::string const&, int)'
main.cpp:(.text+0x34): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
main.cpp:(.text+0x75): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
main.cpp:(.text+0x9d): undefined reference to `cv::waitKey(int)'
main.o: In function `main':

And the Makefile is here:

CC=g++
FLAGS=-L./lib -I./include -I. -lopencv_core -lopencv_highgui -lopencv_imgproc

all: ColorTransfer

ColorTransfer: main.o ColorTransfer.o
    $(CC) $(FLAGS) main.o ColorTransfer.o -o ColorTransfer

main.o: main.cpp 
    $(CC) $(FLAGS) -c main.cpp -o main.o

ColorTransfer.o: ColorTransfer.cpp ColorTransfer.h
    $(CC) $(FLAGS) -c ColorTransfer.cpp -o ColorTransfer.o

clean :
    rm -rf main.o ColorTransfer.o

And current directory contains directory named lib, which has opencv libraries.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In your folder:

 /lib

You have to be sure that there are:

 opencv_core.so
 opencv_highgui.so
 opencv_imgproc.so

And that your LD_LIBRARY_PATH point to this folder. Otherwise, you've to export it:

export LD_LIBRARY_PATH=/lib

Have you download opencv sources or precompiled? Have you configured dynamic linker run-time bindings?

sudo ldconfig

edit

Otherwise, try to check out this soloution!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...