Page 1 of 1

Cannot compile with GDAL

Posted: Tue Dec 05, 2023 8:38 pm
by antoineb
Hi,

I can't seem to understand why the compile stage fails whereas GDAL is installed on my computer.

Code: Select all

/usr/bin/ld: cs_user_initialization.o: in function `cs_user_initialization':
cs_user_initialization.c:(.text+0x6b): undefined reference to `GDALAllRegister'
/usr/bin/ld: cs_user_initialization.c:(.text+0x86): undefined reference to `GDALOpen'
/usr/bin/ld: cs_user_initialization.c:(.text+0x96): undefined reference to `GDALGetDatasetDriver'
/usr/bin/ld: cs_user_initialization.c:(.text+0xa1): undefined reference to `GDALGetDriverLongName'
/usr/bin/ld: cs_user_initialization.c:(.text+0xac): undefined reference to `GDALGetDriverShortName'

And it goes on for a long list.

When i use

Code: Select all

code_saturne compile --libs=-lgdal
it builds but when i launch

Code: Select all

code_saturne run
it fails...

How can I use '-lgdal' for running computation ?

Best regards,
Antoine

Re: Cannot compile with GDAL

Posted: Wed Dec 06, 2023 8:29 pm
by Yvan Fournier
Hello,

Can you run "ldd" on the cs_solver executable in your execution directory, to check that the version of GDAL you are liking to is the one you expect (in cas of multiple installs, for example on in the base system and one in SALOME) ?

Otherwise, is GDAL split into multiple libraries ?

Best regards,

Yvan

Re: Cannot compile with GDAL

Posted: Mon Dec 11, 2023 11:24 am
by antoineb
Hello Yvan,

You can find attached te output of the ldd command.

regarding GDAL :

Code: Select all

 libgdal.so.30 => /usr/lib/libgdal.so.30 (0x00007f0e44df2000)
It is the right library.

Is there a way i can launch computation with the created cs_solver in the SRC directory ?

Best regards,
Antoine

Re: Cannot compile with GDAL

Posted: Mon Dec 11, 2023 7:35 pm
by Yvan Fournier
Hello,

Currently, if this works with "code_saturne compile --libs=-lgdal" but not with "code_saturne run", you probably need to add a cs_user_scripts.py file to your DATA directory and edit the domain.compile_libs entry in that file.

In the future, this option will be moved from cs_user_scripts.py to run.cfg, but this is not the case yet.

Regards,

Yvan

Re: Cannot compile with GDAL

Posted: Mon Dec 18, 2023 11:15 am
by antoineb
Hi Yvan,

I got it to work with the following commands :

Code: Select all

code_saturne compile --libs=-lgdal --source=./SRC --dest=./DATA
cp ./DATA/* ./RESU/test/ 
code_saturne run --no-stage --id test
I tried again on code_saturne v7 which worked just fine before i updated to Debian 12, and it does not work anymore.
I think the issue may be related to Debian 12.

Best regards,
Antoine

Re: Cannot compile with GDAL

Posted: Mon Dec 18, 2023 12:57 pm
by Yvan Fournier
Hello,

There may be another issue with Debian 11 and 12, which seems related to an incorrect behavior of the linker.

If you add
LDFLAGS=-Wl,--no-as-needed
to you initial code_saturne configuration command, you might avoid the issue specific to Debian 12.

I would need to automate a workaround, but the error seems to be in the handling of the "as-needed" behavior of the linker on Debian, which does not "see" required libraries. I have this issue on a (Debian 11 based) Scibian 11 machine, but do not have it under Arch Linux.

Best regards,

Yvan

Re: Cannot compile with GDAL

Posted: Mon Dec 18, 2023 1:05 pm
by antoineb
Hello,

Do you mean using this flag when running a simulation or when installing code_saturne ?

Best regards,
Antoine

Re: Cannot compile with GDAL

Posted: Mon Dec 18, 2023 3:25 pm
by Yvan Fournier
Hello,

I mean When installing code_saturne.

Though you might first simply try passing those options when running as follows:

code_saturne compile --libs="-lgdal -Wl,--no-as-needed"

Best regards,

Yvan

Re: Cannot compile with GDAL

Posted: Wed Dec 20, 2023 9:21 pm
by antoineb
Hi Yvan,

I will try on next install ;)
But everything is working just fine at the moment, so I will keep the solution mentionned before.
I will give an update when trying your fix.

Best regards,
Antoine