Show listing of pre-compiled libs I'm trying to link against.
** listing directory with pre-compiled libs for Raspberry Pi / Arm target **
$ls -al lib/linux/pi/
total 24936
drwxr-xr-x 13 davis staff 442 Sep 24 17:50 .
drwxr-xr-x 4 davis staff 136 Sep 24 17:50 ..
-rw-r--r-- 1 davis staff 803866 Sep 24 17:50 libCppUTest.a
-rw-r--r-- 1 davis staff 288552 Sep 24 17:50 libczmq.a
-rwxr-xr-x 1 davis staff 954 Sep 24 17:50 libczmq.la
-rwxr-xr-x 1 davis staff 201072 Sep 24 17:50 libczmq.so
-rwxr-xr-x 1 davis staff 201072 Sep 24 17:50 libczmq.so.1
-rwxr-xr-x 1 davis staff 201072 Sep 24 17:50 libczmq.so.1.0.0
-rw-r--r-- 1 davis staff 4235478 Sep 24 17:50 libzmq.a
-rwxr-xr-x 1 davis staff 942 Sep 24 17:50 libzmq.la
-rwxr-xr-x 1 davis staff 2268130 Sep 24 17:50 libzmq.so
-rwxr-xr-x 1 davis staff 2268130 Sep 24 17:50 libzmq.so.3
-rwxr-xr-x 1 davis staff 2268130 Sep 24 17:50 libzmq.so.3.0.0
** listing directory with pre-compiled libs for standard Linux / x86 **
$ ls -al lib/linux/x86/
total 25960
drwxr-xr-x 18 davis staff 612 Sep 24 17:50 .
drwxr-xr-x 4 davis staff 136 Sep 24 17:50 ..
-rw-r--r-- 1 davis staff 746964 Sep 24 17:50 libCppUTest.a
-rw-r--r-- 1 davis staff 303330 Sep 24 17:50 libczmq.a
-rwxr-xr-x 1 davis staff 1000 Sep 24 17:50 libczmq.la
-rwxr-xr-x 1 davis staff 208665 Sep 24 17:50 libczmq.so
-rwxr-xr-x 1 davis staff 208665 Sep 24 17:50 libczmq.so.1
-rwxr-xr-x 1 davis staff 208665 Sep 24 17:50 libczmq.so.1.0.0
-rw-r--r-- 1 davis staff 314414 Sep 24 17:50 libjzmq.a
-rwxr-xr-x 1 davis staff 996 Sep 24 17:50 libjzmq.la
-rwxr-xr-x 1 davis staff 188577 Sep 24 17:50 libjzmq.so
-rwxr-xr-x 1 davis staff 188577 Sep 24 17:50 libjzmq.so.0
-rwxr-xr-x 1 davis staff 188577 Sep 24 17:50 libjzmq.so.0.0.0
-rw-r--r-- 1 davis staff 4028054 Sep 24 17:50 libzmq.a
-rwxr-xr-x 1 davis staff 947 Sep 24 17:50 libzmq.la
-rwxr-xr-x 1 davis staff 2220121 Sep 24 17:50 libzmq.so
-rwxr-xr-x 1 davis staff 2220121 Sep 24 17:50 libzmq.so.3
-rwxr-xr-x 1 davis staff 2220121 Sep 24 17:50 libzmq.so.3.0.0
Refer to CMakeLists.txt
below that shows how I'm trying to use find_library()
to resolve the references to these pre-built libraries inside my own project dir structure.
Also, refer to Toolchain-raspberrypi-arm.cmake
which is my cross-compile toolchain file.
If I run cmake ..
on Linux/x86 or Mac OS X, everything is fine. It finds and links with the correct libraries, as expected.
However, if I try to cross-compile, if fails to "find" the libraries like it does on the other platforms -- why?:
$ cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-raspberrypi-arm.cmake ..
Using Raspberry Pi Tools found in /home/davis/git/raspberrypi/tools
CMAKE_CROSSCOMPILING => TRUE
CMAKE_SYSTEM_NAME => Linux, PROJECT_SOURCE_DIR => /home/davis/git/ebike-firmware
CMAKE_CROSSCOMPILING is true...doing find_library for ZeroMQ...
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CZMQ_LIB
linked by target "Runtime" in directory /home/davis/git/ebike-firmware/src
ZEROMQ_LIB
linked by target "Runtime" in directory /home/davis/git/ebike-firmware/src
-- Configuring incomplete, errors occurred!
For those finding this gist, the problem is the
SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
.ONLY
tells cmake to not look inside non-sysroot-dirs for libraries - even if you provided explicitly a path tofind_library()
.What needs to be done is
SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
- then it works