1

I was trying to install opencv in one machine. And I met with an issue: for the library libavcodec-dev there are two copies in the machine, /usr/local/lib and /usr/lib. The version in /usr/lib is compatible with opencv. But CMake found /usr/local/lib first. Could anyone help me? How to configure the cmake to find correct version? Thanks.

Alfred
  • 71
  • 1
  • 7
  • This question has extensive information on how to affect the linking of libs: http://stackoverflow.com/questions/1487752/how-do-i-instruct-cmake-to-look-for-libraries-installed-by-macports – Soren May 07 '16 at 14:17

2 Answers2

3

To specify a specific lib "Foo" found exactly in /usr/lib you should use;

find_library(Foo foo PATHS /usr/lib NO_DEFAULT_PATH)

From the documentation;

If NO_DEFAULT_PATH is specified, then no additional paths are added to the search.

Documentation also goes on to say that the default search for libs are dictated and controlled by the CMAKE_LIBRARY_PATH env variable.

Soren
  • 14,402
  • 4
  • 41
  • 67
1
find_library(AVCODEC avcodec-dev PATHS /usr/lib NO_DEFAULT_PATH)
John Zwinck
  • 239,568
  • 38
  • 324
  • 436