Cannot compile with GDAL

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
antoineb
Posts: 26
Joined: Mon Sep 16, 2019 4:06 pm

Cannot compile with GDAL

Post 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
Attachments
cs_user_initialization.c
(17.08 KiB) Downloaded 547 times
cs_user_boundary_conditions.c
(4.66 KiB) Downloaded 506 times
compile.log
(23.71 KiB) Downloaded 475 times
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Cannot compile with GDAL

Post 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
antoineb
Posts: 26
Joined: Mon Sep 16, 2019 4:06 pm

Re: Cannot compile with GDAL

Post 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
Attachments
libs.txt
(9.97 KiB) Downloaded 209 times
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Cannot compile with GDAL

Post 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
antoineb
Posts: 26
Joined: Mon Sep 16, 2019 4:06 pm

Re: Cannot compile with GDAL

Post 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
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Cannot compile with GDAL

Post 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
antoineb
Posts: 26
Joined: Mon Sep 16, 2019 4:06 pm

Re: Cannot compile with GDAL

Post by antoineb »

Hello,

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

Best regards,
Antoine
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Cannot compile with GDAL

Post 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
antoineb
Posts: 26
Joined: Mon Sep 16, 2019 4:06 pm

Re: Cannot compile with GDAL

Post 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
Post Reply