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

Support OpenJPEG 2.5 #623

Closed
VVD opened this issue May 31, 2022 · 12 comments
Closed

Support OpenJPEG 2.5 #623

VVD opened this issue May 31, 2022 · 12 comments

Comments

@VVD
Copy link

VVD commented May 31, 2022

Build failed with OpenJPEG 2.5.0 - there are no check for includes openjpeg-2.5/openjpeg.h.
Found list of files with check for OpenJPEG:
CMakeLists.txt
cmake/Configure.cmake
config/config.h.in

Will try to fix this and show patches in comments.

@VVD
Copy link
Author

VVD commented May 31, 2022

Build fine for me on FreeBSD 12.3 amd64 with patches below.

CMakeLists.txt:

--- CMakeLists.txt.orig
+++ CMakeLists.txt
@@ -141,6 +141,17 @@
                     set(HAVE_LIBJP2K 1)
                 endif()
             endif()
+            if(NOT JP2K)
+                find_path(JP2K_INCLUDE_DIR /openjpeg-2.5/openjpeg.h)
+                find_library(JP2K_LIBRARY NAMES openjp2)
+                if (JP2K_INCLUDE_DIR AND JP2K_LIBRARY)
+                    set(JP2K 1)
+                    set(JP2K_FOUND TRUE)
+                    set(JP2K_LIBRARIES ${JP2K_LIBRARY})
+                    set(JP2K_INCLUDE_DIRS ${JP2K_INCLUDE_DIR})
+                    set(HAVE_LIBJP2K 1)
+                endif()
+            endif()
             set(libs_private "${libs_private} -lopenjp2")
         endif()
     endif()

cmake/Configure.cmake:

--- cmake/Configure.cmake.orig
+++ cmake/Configure.cmake
@@ -69,6 +69,7 @@
     openjpeg-2.2/openjpeg.h
     openjpeg-2.3/openjpeg.h
     openjpeg-2.4/openjpeg.h
+    openjpeg-2.5/openjpeg.h
 )
 check_includes(include_files_list)

@@ -146,7 +147,9 @@
 /* Define to 1 if you have zlib. */
 #cmakedefine HAVE_LIBZ 1

-#if defined(HAVE_OPENJPEG_2_4_OPENJPEG_H)
+#if defined(HAVE_OPENJPEG_2_5_OPENJPEG_H)
+#define LIBJP2K_HEADER <openjpeg-2.5/openjpeg.h>
+#elif defined(HAVE_OPENJPEG_2_4_OPENJPEG_H)
 #define LIBJP2K_HEADER <openjpeg-2.4/openjpeg.h>
 #elif defined(HAVE_OPENJPEG_2_3_OPENJPEG_H)
 #define LIBJP2K_HEADER <openjpeg-2.3/openjpeg.h>

config/config.h.in:

--- config/config.h.in.orig
+++ config/config.h.in
@@ -51,6 +51,12 @@
 /* Define to 1 if you have the <openjpeg-2.3/openjpeg.h> header file. */
 #undef HAVE_OPENJPEG_2_3_OPENJPEG_H

+/* Define to 1 if you have the <openjpeg-2.4/openjpeg.h> header file. */
+#undef HAVE_OPENJPEG_2_4_OPENJPEG_H
+
+/* Define to 1 if you have the <openjpeg-2.5/openjpeg.h> header file. */
+#undef HAVE_OPENJPEG_2_5_OPENJPEG_H
+
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H

@stweil
Copy link
Collaborator

stweil commented May 31, 2022

Maybe a better solution is using pkg-config to check whether OpenJPEG is available and to get the necessary compiler and linker flags. That would also work for a future OpenJPEG 2.6.

@zdenop
Copy link
Collaborator

zdenop commented May 31, 2022

pkg-config is not standard on all platform (e.g. Windows) ;-)
using find_package(OpenJPEG) should be better solution for cmake...

@stweil
Copy link
Collaborator

stweil commented May 31, 2022

Builds with autoconf already use pkg-config and should work with OpenJPEG 2.5. And yes, for cmake builds find_package would be the best solution.

@VVD
Copy link
Author

VVD commented May 31, 2022

Don't think I can implement this in near future.
If you can please do it. And maybe next release just after this. :-]
Thanks!

@zdenop
Copy link
Collaborator

zdenop commented May 31, 2022

#624 should solve it. Please test it.

@VVD
Copy link
Author

VVD commented Jun 17, 2022

#624 should solve it. Please test it.

Thanks.
But I can't apply patch to last release version without errors. What list of commits it require?
I explore a bit and it's look like hard work to separate required commits.

The easiest option for me is to release a new version and I can test it.

@zdenop
Copy link
Collaborator

zdenop commented Jun 17, 2022

There is no need to patch anything - just download the recent code:
image

@VVD
Copy link
Author

VVD commented Jun 17, 2022

I know this possibility, but I build via FreeBSD ports.
To do this I must modify this port. It use releases and change it to use last version from git is not so fast and trivial work.

@VVD
Copy link
Author

VVD commented Jun 17, 2022

I "made release" 1.82.1 from git master:

cd /usr/ports/distfiles
wget https://github.com/DanBloomberg/leptonica/archive/refs/heads/master.zip
unzip master.zip
mv leptonica-master leptonica-1.82.1
tar -zcf leptonica-1.82.1.tar.gz leptonica-1.82.1
cd /usr/ports/graphics/leptonica
# fix version from 1.82.0 to 1.82.1 and remove extra patches from commits
vi Makefile
make makesum
make

Build without errors.

@VVD
Copy link
Author

VVD commented Jun 20, 2022

In 3 words: work for me. :-]

@VVD
Copy link
Author

VVD commented Jun 20, 2022

Waiting release.

@VVD VVD closed this as completed Jun 20, 2022
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Jul 18, 2022
ChangeLog: DanBloomberg/leptonica#623

Fix detection of openjpeg 2.5.0

PR:     264684
Reported by:    vvd@unislabs.com
Approved by:    hiroto.kagotani@gmail.com (maintainer, timeout > 1 month)
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