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

LINUX install doesn't work when building shared libraries is disabled #1155

Closed
RochaStratovan opened this issue Oct 17, 2018 · 6 comments
Closed

Comments

@RochaStratovan
Copy link

cmake error.

If we use cmake on Linux and disable shared libraries and do not build the codec then the install logic for the generated library fails. And causes an error message of:

CMake Error: INSTALL(EXPORT) given unknown export "OpenJPEGTargets"

Moreover when make install is invoked, it will not copy the static .a library file to the desired target.

Below is an example reproduction:
`cmake .. \

-DCMAKE_BUILD_TYPE=RELEASE
-DBUILD_SHARED_LIBS:bool=off
-DBUILD_CODEC:bool=off
-DCMAKE_INSTALL_PREFIX:path="./INSTALL"
-DOPENJPEG_INSTALL_LIB_DIR:string="test/lib"
-DOPENJPEG_INSTALL_BIN_DIR:string="test/bin/"
-DOPENJPEG_INSTALL_INCLUDE_DIR:string="test/include"
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for string.h
-- Looking for string.h - found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for stdio.h
-- Looking for stdio.h - found
-- Looking for math.h
-- Looking for math.h - found
-- Looking for float.h
-- Looking for float.h - found
-- Looking for time.h
-- Looking for time.h - found
-- Looking for stdarg.h
-- Looking for stdarg.h - found
-- Looking for ctype.h
-- Looking for ctype.h - found
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Checking for 64-bit off_t
-- Checking for 64-bit off_t - present
-- Checking for fseeko/ftello
-- Checking for fseeko/ftello - present
-- Large File support - found
-- Looking for include file malloc.h
-- Looking for include file malloc.h - found
-- Looking for _aligned_malloc
-- Looking for _aligned_malloc - not found
-- Looking for posix_memalign
-- Looking for posix_memalign - found
-- Looking for memalign
-- Looking for memalign - found
-- Configuring done
CMake Error: INSTALL(EXPORT) given unknown export "OpenJPEGTargets"
-- Generating done
-- Build files have been written to: ....openjpeg/openjpeg-2.3.0/Build
`

I've root caused the problem to src/lib/openjp2/CMakeLists.txt.

The logic for installing the library:
# Install library install(TARGETS ${INSTALL_LIBS} EXPORT OpenJPEGTargets RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries ARCHIVE DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries )

uses the variable ${INSTALL_LIBS}, however this variable is only set for LINUX if BUILD_SHARED_LIBS and BUILD_STATIC_LIBS are both true. However I have shared libraries turned off.

The workaround I've found is to just set INSTALL_LIBS to openjp2.

@rouault
Copy link
Collaborator

rouault commented Oct 17, 2018

I believe this is a duplicate of #1019 ? Could you try master and/or apply 66297f0 ?

@RochaStratovan
Copy link
Author

RochaStratovan commented Oct 17, 2018 via email

@rouault
Copy link
Collaborator

rouault commented Oct 17, 2018

@szukw000
Copy link
Contributor

@RochaStratovan , @rouault ,
using 'openjpeg-master-2016-04-15' and the following shell script:

#!/bin/sh
cmake -DCMAKE_INSTALL_PREFIX:path="./INSTALL" -DBUILD_DOC:bool=on -DBUILD_PKGCONFIG_FILES:bool=on -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_VIEWER:bool=off -DBUILD_JAVA:bool=off -DBUILD_JPIP_SERVER:bool=on -DBUILD_SHARED_LIBS:bool=off -DBUILD_MJ2:bool=on -DBUILD_JP3D:bool=on -DBUILD_JPWL:bool=off -DBUILD_JPIP:bool=on -DCMAKE_INSTALL_PREFIX=./INSTALL ..

root: ls INSTALL/lib/
libopenjp2.a libopenjpip.a libopenmj2.a pkgconfig/
libopenjp3d.a libopenjpip_server.a openjpeg-2.1/

root: ls INSTALL/bin
opj_compress opj_jp3d_compress opj_jpip_transcode opj_mj2_wrap
opj_dec_server opj_jp3d_decompress opj_mj2_compress opj_server
opj_decompress opj_jpip_addxml opj_mj2_decompress
opj_dump opj_jpip_test opj_mj2_extract

winfried

@szukw000
Copy link
Contributor

@RochaStratovan , @rouault ,
I have forgotten to mention:

  1. The cmake-line of the shell script is ONE line.
  2. My gcc-version is 8.2.0, my cmake-version is 3.12.1 .
    winfried

@RochaStratovan
Copy link
Author

Hello @rouault ,

I retested with the master.zip as you instructed and it now works as expected.

Thank you for your help.

John

BUILD$ cmake .. \
> -DCMAKE_BUILD_TYPE=RELEASE  \
> -DBUILD_SHARED_LIBS:bool=off  \
> -DBUILD_CODEC:bool=off  \
> -DCMAKE_INSTALL_PREFIX:path="./INSTALL"  \
> -DOPENJPEG_INSTALL_LIB_DIR:string="test/lib"  \
> -DOPENJPEG_INSTALL_BIN_DIR:string="test/bin/"  \
> -DOPENJPEG_INSTALL_INCLUDE_DIR:string="test/include"
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for string.h
-- Looking for string.h - found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for stdio.h
-- Looking for stdio.h - found
-- Looking for math.h
-- Looking for math.h - found
-- Looking for float.h
-- Looking for float.h - found
-- Looking for time.h
-- Looking for time.h - found
-- Looking for stdarg.h
-- Looking for stdarg.h - found
-- Looking for ctype.h
-- Looking for ctype.h - found
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Checking for 64-bit off_t
-- Checking for 64-bit off_t - present
-- Checking for fseeko/ftello
-- Checking for fseeko/ftello - present
-- Large File support - found
-- Looking for include file malloc.h
-- Looking for include file malloc.h - found
-- Looking for _aligned_malloc
-- Looking for _aligned_malloc - not found
-- Looking for posix_memalign
-- Looking for posix_memalign - found
-- Looking for memalign
-- Looking for memalign - found
-- Configuring done
-- Generating done
-- Build files have been written to: .../BUILD

...
...

BUILD$ make install
Scanning dependencies of target openjp2
[  4%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/thread.c.o
[  9%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/bio.c.o
[ 13%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/cio.c.o
[ 18%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/dwt.c.o
[ 22%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/event.c.o
[ 27%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/image.c.o
[ 31%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/invert.c.o
[ 36%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/j2k.c.o
[ 40%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/jp2.c.o
[ 45%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/mct.c.o
[ 50%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/mqc.c.o
[ 54%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/openjpeg.c.o
[ 59%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/opj_clock.c.o
[ 63%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/pi.c.o
[ 68%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/t1.c.o
[ 72%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/t2.c.o
[ 77%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/tcd.c.o
[ 81%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/tgt.c.o
[ 86%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/function_list.c.o
[ 90%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/opj_malloc.c.o
[ 95%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/sparse_array.c.o
[100%] Linking C static library ../../../bin/libopenjp2.a
[100%] Built target openjp2
Install the project...
-- Install configuration: "RELEASE"
-- Installing: /media/sf_Perforce/test/openjpeg-master/BUILD/./INSTALL/test/lib/openjpeg-2.3/OpenJPEGTargets.cmake
-- Installing: /media/sf_Perforce/test/openjpeg-master/BUILD/./INSTALL/test/lib/openjpeg-2.3/OpenJPEGTargets-release.cmake
-- Installing: /media/sf_Perforce/test/openjpeg-master/BUILD/./INSTALL/test/lib/openjpeg-2.3/OpenJPEGConfig.cmake
-- Installing: /media/sf_Perforce/test/openjpeg-master/BUILD/./INSTALL/test/lib/pkgconfig/libopenjp2.pc
-- Installing: /media/sf_Perforce/test/openjpeg-master/BUILD/./INSTALL/test/include/opj_config.h
-- Installing: /media/sf_Perforce/test/openjpeg-master/BUILD/./INSTALL/test/lib/libopenjp2.a
-- Installing: /media/sf_Perforce/test/openjpeg-master/BUILD/./INSTALL/test/include/openjpeg.h
-- Installing: /media/sf_Perforce/test/openjpeg-master/BUILD/./INSTALL/test/include/opj_stdint.h

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

3 participants