Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX m1 v2.5.0 build fail #1430

Closed
VoidVolker opened this issue Jun 13, 2022 · 6 comments
Closed

OSX m1 v2.5.0 build fail #1430

VoidVolker opened this issue Jun 13, 2022 · 6 comments

Comments

@VoidVolker
Copy link

Expected behavior and actual behavior.

Expected: build completed.
Actual: build failed.

Error:

Linking C executable ../../../bin/opj_decompress
ld: library not found for -ltiff
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/opj_decompress] Error 1
make[1]: *** [src/bin/jp2/CMakeFiles/opj_decompress.dir/all] Error 2
make: *** [all] Error 2

Steps to reproduce the problem.

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Operating system

OSX 12.4 m1

openjpeg version

v2.5.0

Additional info

v2.4.0 - build works ok.

brew info libtiff
libtiff: stable 4.4.0 (bottled)
TIFF library and utilities
https://libtiff.gitlab.io/libtiff/
/opt/homebrew/Cellar/libtiff/4.4.0 (249 files, 4.8MB) *
@szukw000
Copy link
Contributor

@VoidVolker,
I had the same link error with MAC

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

and did succeed with adding

cmake -DBUILD_THIRDPARTY:BOOL=ON

winfried

@landryb
Copy link

landryb commented Jun 27, 2022

from my analysis that's a regression from #866, i'm seeing the same failure on OpenBSD when trying to update openjp2 from 2.4.0 to 2.5.0.

FAILED: bin/opj_decompress 
: && /usr/obj/ports/openjp2-2.5.0/bin/cc -O2 -pipe -g -DNDEBUG  src/bin/jp2/CMakeFiles/opj_decompress.dir/opj_decompress.c.o src/bin/jp2/CMakeFiles/opj_decompress.dir/convert.c.o src/bin/jp2/CMakeFiles/opj_decompress.dir/convertbmp.c.o src/bin/jp2/CMakeFiles/opj_decompress.dir/index.c.o src/bin/jp2/CMakeFiles/opj_decompress.dir/__/common/color.c.o src/bin/jp2/CMakeFiles/opj_decompress.dir/__/common/opj_getopt.c.o src/bin/jp2/CMakeFiles/opj_decompress.dir/converttif.c.o src/bin/jp2/CMakeFiles/opj_decompress.dir/convertpng.c.o -o bin/opj_decompress  -Wl,-z,origin,-rpath,/usr/obj/ports/openjp2-2.5.0/build-amd64/bin:/usr/local/lib:  bin/libopenjp2.so.4.0  /usr/local/lib/libpng.so.18.0  /usr/lib/libz.so.6.1  /usr/local/lib/libtiff.so.41.1  -ltiff  -lzstd  -llzma  -ljpeg  -lz  -lm  /usr/local/lib/liblcms2.so.1.4  -llcms2  -lm  -lpthread  /usr/lib/libz.so.6.1  -lm  -lpthread  /usr/local/lib/libtiff.so.41.1  -ltiff  -lzstd  -llzma  -ljpeg  -lz  /usr/local/lib/liblcms2.so.1.4  -llcms2  -lpthread  -lm  -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib && :
ld: error: unable to find library -ltiff
ld: error: unable to find library -lzstd
ld: error: unable to find library -llzma
ld: error: unable to find library -ljpeg
ld: error: unable to find library -llcms2
ld: error: unable to find library -ltiff
ld: error: unable to find library -lzstd
ld: error: unable to find library -llzma
ld: error: unable to find library -ljpeg
ld: error: unable to find library -llcms2

cmake now uses pkg-config to detect libtiff even with dynamic linking, but only uses TIFF_LIBNAME & TIFF_INCLUDE_DIRNAME, while i think TIFF_LIBDIR should also be used so that cmake finds the tiff library where it's installed (in our case, /usr/local/lib like any third-party deps)

same thing might be needed for LCMS as something similar was done in #867.

@rouault ? i've tried adding link_directories(${TIFF_LIBDIR}) to src/bin/jp2/CMakeLists.txt but that didnt help.

@landryb
Copy link

landryb commented Jun 27, 2022

build.ninja ends up with

LINK_LIBRARIES = -Wl,-z,origin,-rpath,/usr/obj/ports/openjp2-2.5.0/build-amd64/bin:/usr/local/lib:  bin/libopenjp2.so.4.0  /usr/local/lib/libpng.so.18.0  /usr/lib/libz.so.6.1  /usr/local/lib/libtiff.so.41.1  -ltiff  -lzstd  -llzma  -ljpeg  -lz  -lm  /usr/local/lib/liblcms2.so.1.4  -llcms2  -lm  -lpthread  /usr/lib/libz.so.6.1  -lm  -lpthread  /usr/local/lib/libtiff.so.41.1  -ltiff  -lzstd  -llzma  -ljpeg  -lz  /usr/local/lib/liblcms2.so.1.4  -llcms2  -lpthread  -lm  -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib

which doesnt have -L/usr/local/lib.

$pkg-config --libs libtiff-4
-L/usr/local/lib -ltiff
$pkg-config --libs --static libtiff-4
-L/usr/local/lib -ltiff -lzstd -llzma -ljpeg -lz -lm

dropping ${PC_TIFF_STATIC_LIBRARIES} and ${PC_LCMS2_STATIC_LIBRARIES} from thirdparty/CMakeFiles.txt allows me to build fine.

rouault added a commit to rouault/openjpeg that referenced this issue Jun 27, 2022
…atic libraries are not in system directories (fixes uclouvain#1430)

Note that the fix might be partial only for static-only builds (cf
comments)
@rouault
Copy link
Collaborator

rouault commented Jun 27, 2022

Does #1431 f ix things for people having issues ?

@landryb
Copy link

landryb commented Jun 27, 2022

yes #1431 also works for me

@VoidVolker
Copy link
Author

Does #1431 f ix things for people having issues ?

Yes, it works. Thanks!

rouault added a commit that referenced this issue Jun 27, 2022
Build: fix linking of executables on some systems where TIFF/LCMS2 static libraries are not in system directories (fixes #1430)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants