[gdal-dev] OpenJPEG JPEG2000 Driver

Simon Eves simon.eves at heavy.ai
Tue Feb 14 16:40:32 PST 2023


OK, I'm an idiot. It's *CMAKE_C_FLAGS* not *CMAKE_CPP_FLAGS*. It works now.

However, I am still surprised at the need to hack the *configure* script to
make the test work.


On Tue, Feb 14, 2023 at 4:33 PM Simon Eves <simon.eves at heavy.ai> wrote:

> I recreated the compile/link test that *configure* is doing, and it also
> fails outside.
>
> I then determined I could make it work by also adding *-lm* and
> *-lpthread* to the link.
>
> I hacked GDAL *configure* script to also add those two to *$LIBS* when it
> does the OpenJPEG link test, and now that passes, and then *configure*
> reports OpenJPEG is enabled.
>
> However, when I then compile GDAL, it fails in the final huge link of *libgdal.la
> <http://libgdal.la>* with
>
>
> */usr/bin/ld: /usr/local/mapd-deps/lib/libopenjp2.a(cio.c.o): relocation
> R_X86_64_PC32 against symbol `opj_stream_write_skip' can not be used when
> making a shared object; recompile with -fPIC/usr/bin/ld: final link failed:
> bad value*
>
> I assume this is because it's trying to make a shared GDAL lib, but
> including the static OpenJPEG lib.
>
> I tried adding * -DCMAKE_CPP_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC"* to
> the OpenJPEG build CMake invocation, but that made no difference.
>
> Any help with this would be greatly appreciated, as we're code-freezing
> end of this week and I'd really like to get this in.
>
>
>
> On Sun, Feb 12, 2023 at 6:44 PM Simon Eves <simon.eves at heavy.ai> wrote:
>
>> Is there some trick to enabling this driver with the old non-CMake build
>> env...? :)
>>
>> I am building OpenJPEG 2.5.0 (from source) and it's building and
>> installing fine into the same include/lib tree as everything else, and then
>> GDAL configure (just adding *--with-openjpeg*, no path, right?) sees it
>> and tests it, but the compile test of *opj_setup_decoder()* apparently
>> fails, so *HAVE_OPENJPEG* gets disabled again.
>>
>> I see that function in *openjpeg.h* and (with *nm*) in *libopenjp2.a*,
>> so I'm not sure why it's failing.
>>
>> I tried some other CMake option variations for OpenJPEG but nothing fixed
>> it.
>>
>> Ubuntu 20.04, GCC 9.4, GDAL 3.4.1, all-static build
>>
>> I have tried GDAL 3.6.2 (and PROJ 9.2.1) building them with CMake and I
>> think the OpenJPEG part is working, then but our dependencies build falls
>> over later with something else that doesn't like the newer PROJ, and I'd
>> rather not bump the GDAL & PROJ and data files versions at this time
>> anyway, as we're very close to a release.
>>
>> I just wanna minimally add JPEG2000 to what we have...
>>
>> TIA
>>
>> --
>> Simon Eves
>> Senior Rendering Engineer
>> +1 (415) 902-1996
>> simon.eves at heavy.ai
>>
>> <http://www.heavy.ai>
>>
>> (formerly OmniSci)
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230214/421319aa/attachment-0001.htm>


More information about the gdal-dev mailing list