Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Error in generating .exe when compiling SWAT+ on Linux

97 views
Skip to first unread message

Ann Wang

unread,
Nov 5, 2024, 11:48:57 AM11/5/24
to SWAT+
Hello SWAT+ community:

I'm compiling SWAT+ (download directly from its official github page) on Linux. All the .f90 sources files have been successfully compiled into '.f90.o' files. But the compile process runs into error in merging all *.f90.o files into a single executable file, which is line 9696 in the "CMakeFiles/swatplus-unknown-gcc-lin_x86_64.dir/build.make". The error message 'cannot find -lm & -lc,' as shown in the attached picture, seems to indicate that some libraries are missing from my environment.

Can anyone help to identify the specific libraries that the error message is indicating?

Many thanks,
Ann

Screenshot 2024-11-04 153334.png

Olaf David

unread,
Nov 18, 2024, 9:18:05 AM11/18/24
to SWAT+
Hi Ann,
 it seems like you are missing 'libm.a' and 'libc.a' for statically linking. Those are basic libraries (math and C) that should be installed. On a Debian based system, they are in '/usr/lib/x86_64-linux-gnu'. I'd recommend re-installing gcc/gfortran and then try to compile a very simple Fortran program. If that works then rebuild swat, but delete the folder 'build' first.  If that still fails, please post the file 'link.txt' from the 'swatplus-unknown-gcc-lin_x86_64.dir' folder.

BTW. If you just want to run the model, you can download the executables from Github. I recommend using the ifx builds, since swat for gfortran still needs adjustments. 

Hope this helps.

--od

Vivek Tiwari

unread,
Jan 2, 2025, 10:43:20 AMJan 2
to SWAT+
I am encountering the same error as well. Could you please let me know if you were able to resolve it?

Natalja C.

unread,
Jan 2, 2025, 11:26:11 AMJan 2
to SWAT+
Hello,

Adjusting the CMakeLists.txt will fix the issue:
lines 49-52 from:

        if(NOT APPLE)

            link_libraries("")

        endif()

to:

        if(NOT APPLE)

            # link_libraries("-static")

            link_libraries("")

        endif()

 

This will disable statically linked compile for gfortran.

Best,
Natalja

Vivek Tiwari

unread,
Jan 3, 2025, 10:00:34 PMJan 3
to SWAT+
Adjusting the CMakeLists.txt as you recommended fixed the issue, and I was able to create the executable successfully.
Thank you so much for your help.

Ann Wang

unread,
Jan 17, 2025, 4:06:42 PMJan 17
to SWAT+
Yes, the tips from Natalja work. Thanks!. And for the ifort compiler, users need to modify the code at line 37 in CMakeLists.txt to "link_libraries("")".
Reply all
Reply to author
Forward
0 new messages