Closed leleliu008 closed 4 months ago
@leleliu008 First, please always submit proposed code changes in the form of a pull request. There are many reasons why this is beneficial (e.g., being able to automatically run CI test cases on the modified code). Second, your change looks non-portable and I think that it may break things on some systems. CMake will set PTHREAD_LIBRARY to the correct library value for the platform in question. We should not really override it. Also, what is in the file project-after.cmake? This information seems to be missing.
project-after.cmake file content is following:
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so")
I change the default behaver, I perfer to use static library, that code tell cmake find static library first. On glibc based GNU/Linux, creating a dynamically linked executable cannot link static library of libm
@leleliu008 I'm sorry. Somehow I missed the contents of the file from your original post. I am unclear why you want .so library suffixes when building JasPer as a static library. I am not sure if I understood the problem report link that you sent but it seems that there is an issue with mixing shared and static libraries? Is this correct? Some commentary would be helpful. Also, what specific platform are you using (e.g., OS, version, architecture, etc.)? Do you have this problem if you build JasPer as a shared library? I am also curious why you are using -DJAS_STDC_VERSION. I think that this should only be needed when crosscompiling.
https://sourceware.org/bugzilla/show_bug.cgi?id=21264 this link tell us why this problem has happened. It says on glibc based GNU/Linux, creating a dynamically linked executable cannot link libm.a
, but find_library(MATH_LIBRARY m)
got /usr/lib/x86_64-linux-gnu/libm-2.35.a
because I set set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so")
, that means I changed the default behaver, I perfer to use static library, that code tell cmake find static library first.
I am also curious why you are using -DJAS_STDC_VERSION. I think that this should only be needed when crosscompiling.
I wrote a package manager, my package manager can do both native build and cross build.
what specific platform are you using (e.g., OS, version, architecture, etc.)?
my build machine os is ubuntu-22.04 x86_64
, a glibc base GNU/Linux, ubuntu
I am unclear why you want .so library suffixes when building JasPer as a static library.
This problem happened when building src/app/imginfo
, not when build libjasper
maybe reported error messages are too long? I give you a screenshot, this may looks clear.
The problem appears to be that you are trying to link with a mix of static and shared libraries that are not compatible. In particular, it appears that you are using a shared C library but a static math library (libm). The problem that you are experiencing is caused by your project-after.cmake, however. I can reproduce your problem in Ubuntu 23.10, which you are using above, if I use your project-after.cmake file. If I do not use the project-after.cmake file, everything works fine for me, even when JasPer is built with JAS_ENABLED_SHARED=0. So, in this sense, there is no bug in JasPer. The problem is that you are effectively modifying that build of jasPer via the CMAKE_PROJECT_INCLUDE setting (and your project-after.cmake file), and then blaming JasPer when this breaks things. But it is not really JasPer's fault. You should not modify the build in this way, as it will lead to the types of problems that you are seeing.
Thank you for your comments. I will close this then.
source code
https://github.com/jasper-software/jasper/releases/download/version-4.2.2/jasper-4.2.2.tar.gz
my build machine os information
reported error messages
cmake configure command
project-after.cmake
reason
https://sourceware.org/bugzilla/show_bug.cgi?id=21264
my fix