About Makefile can't find libraries

前端 未结 2 637
死守一世寂寞
死守一世寂寞 2020-12-04 04:02

The Exception is here:

g++ -L/usr/local/lib -I./include -I. -lopencv_core -lopencv_highgui -lopencv_imgproc main.o ColorTransfer.o
main.o: I         


        
相关标签:
2条回答
  • 2020-12-04 04:35

    You really should pay attention to the order of arguments to g++ ; it matters a lot (libraries should go last in good order - highest level to lowest level).

    Use  make -p to learn about rules known to make.... Then improve your Makefile as follow

     CXX=g++
     CXXFLAGS= -I./include -I. -g -Wall
     LDLIBS= -L./lib -lopencv_core -lopencv_highgui -lopencv_imgproc
    
     all: ColorTransfer
    
     ColorTransfer: main.o ColorTransfer.o
               $(LINK.cc)  $^ $(LDLIBS) -o $@
    
     # etc....
    

    I leave you to correct the other lines of your Makefile ... See also this answer ...

    I corrected my make rules above : $^ has to be before $(LDLIBS) !

    BTW, remake is a nice tool to debug Makefile-s; for instance, with remake -x

    0 讨论(0)
  • 2020-12-04 04:36

    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!

    0 讨论(0)
提交回复
热议问题