Linking errors when compiling code with OpenCV Libraries

后端 未结 3 1803
耶瑟儿~
耶瑟儿~ 2020-12-14 19:46

I\'m trying to compile a sample program after installing Opencv with the command:

g++ hello-world.cpp -o hello-world -I /usr/local/include/opencv -L /usr/loc         


        
相关标签:
3条回答
  • 2020-12-14 20:20

    You need to add another -L argument specifying the actual location of the OpenCV libraries.

    0 讨论(0)
  • 2020-12-14 20:28

    UPDATED-

    Better use this command:

    g++ opencv.cpp -o opencv -L `pkg-config --cflags --libs opencv`
    

    The pkg-config command will locate the correct include and library for your source code.
    For better handling with OpenCV programming go with an IDE like code::block.

    Maybe this tutorial will help you in OpenCV programming with code::block:
    How to Setup OpenCV for code :: block in Linux and Windows?

    0 讨论(0)
  • 2020-12-14 20:45

    Recently I started using OpenCV and I got similar problem and for me this works really well:

    -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
    

    Hope it will solve your problem.

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