iMac Catalina and cmake-3.19.3

I have a project that uses fltk, libjpeg and libz.

The cmake configuration file contains:

cmake \

-DCMAKE_BUILD_TYPE:string=“Release” \

-DZLIB_INCLUDE_DIR:path="/usr/local/include" \

-DZLIB_LIBRARY:path="/usr/local/lib/libz.dylib" \

-DJPEG_LIBRARY:path="/usr/local/lib/libjpeg.dylib" \

-DJPEG_INCLUDE_DIR:path="/usr/local/include" \

CMakeCache.txt contains:

JPEG_INCLUDE_DIR:STRING=/usr/local/include

JPEG_LIBRARY:FILEPATH=/usr/local/lib/libjpeg.dylib

ZLIB_INCLUDE_DIR:STRING=/usr/local/include

ZLIB_LIBRARY:FILEPATH=/usr/local/lib/libz.dylib

But the compilation fails:

– Found ZLIB: /usr/local/lib/libz.dylib (found version “1.2.11”)

– JPEG_INCLUDE_DIR : /usr/local/include #MESSAGE in FindJPEG.cmake
– JPEG_LIBRARY : /usr/local/lib/libjpeg.dylib #MESSAGE in FindJPEG.cmake
– Found JPEG: /usr/local/lib/libjpeg.dylib (found version “62”)

ld: library not found for -ljpeg
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The JPEG library is compile and installed using libjpeg-turbo.

Does anybody know what is wrong or missing here?

winfried

What is using -ljpeg? CMake uses full library paths where possible, so something else must be adding that flag. Is there some more context available?

  • how is jpeg linked (i.e., the target_link_libraries call)
  • what is the link line (ninja -v or make VERBOSE=1)

Inspecting my CMakeLists.txt I found the reason of the bug. I used FLTK_CONFIG_SCRIPT to find

the necessary libraries. LINUX and WIN10 never complained.

Now I simply use FLTK_LIBRARY:

– FLTK_LIBRARY ==> /usr/local/fltk14/lib64/libfltk_images.so;/usr/local/fltk14/lib64/libfltk_forms.so;/usr/local/fltk14/lib64/libfltk.so;/usr/lib64/libSM.so;/usr/lib64/libICE.so;/usr/lib64/libX11.so;/usr/lib64/libXext.so;/usr/lib64/libm.so

Thanks for your help.

winfried