Skip to content
Advertisement

How to use CHECK_LIBRARY_EXISTS in cmake?

Here’s what I have in my CMakeLists.txt:

JavaScript

Result:

JavaScript

The symbol exists in that library:

JavaScript

Why cmake doesn’t find that?

Advertisement

Answer

It was dependencies.

CHECK_LIBRARY_EXISTS is much more complex than nm -D. CMake actually creates a C project that references that library, and tries to link it.

I missed some dependencies used by that library (libdrm-dev, libxcb-dri2-0, libx11-xcb-dev), so the linker failed.

Resolved by looking what’s in CMakeFiles folder, it contains much more detailed logs.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement