lephare-photoz / lephare

LePHARE is a code for calculating photometric redshifts.
MIT License
5 stars 1 forks source link

compilation errors #230

Closed Bovornpratch closed 1 week ago

Bovornpratch commented 2 weeks ago

Hi,

First, thanks a lot for your effort in modernizing this code. I have been using the Fortran version of LePhare for quite some time. Now I want to try the c++ version for my work.

I have downloaded the stable version on the LAM gitlab repo and try to compile it on my system but I am getting some errors when compiling zphota (see below). I can't tell if it is due to my compiler or not since I am not super familiar with C++ . I was hoping you could help shed some light on this for me.

My system is basically a Rocky linux 8.8 (basically Redhat/Fedora) with gcc version 8.5.0. I am using the default CFLAGS

CFLAGS = -ggdb -std=c++17 -Ofast -fopenmp -Wall -fno-inline -march=native -mtune=native -mno-vzeroupper -funroll-loops -floop-unroll-and-jam -fomit-frame-pointer -finline -mavx2 -ftree-vectorize

ERROR message

lephare_lib.a(onesource.o): In function onesource::writeSpec(std::vector<SED*, std::allocator<SED*> >&, std::vector<SED*, std::allocator<SED*> >&, cosmo, std::vector<opa, std::allocator<opa> >, std::vector<flt, std::allocator<flt> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)': /usr/include/c++/8/bits/fs_path.h:185: undefined reference tostd::filesystem::cxx11::path::_M_split_cmpts()' lephare_lib.a(onesource.o): In function `onesource::writeSpec(std::vector<SED, std::allocator<SED> >&, std::vector<SED, std::allocator<SED> >&, cosmo, std::vector<opa, std::allocator >, std::vector<flt, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator >)': /usr/include/c++/8/bits/fs_ops.h:121: undefined reference to std::filesystem::status(std::filesystem::__cxx11::path const&)' lephare_lib.a(onesource.o): In functiononesource::writeSpec(std::vector<SED, std::allocator<SED> >&, std::vector<SED, std::allocator<SED> >&, cosmo, std::vector<opa, std::allocator >, std::vector<flt, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >)': /usr/include/c++/8/bits/fs_path.h:185: undefined reference to std::filesystem::__cxx11::path::_M_split_cmpts()' lephare_lib.a(onesource.o): In functiononesource::writeSpec(std::vector<SED, std::allocator<SED> >&, std::vector<SED, std::allocator<SED> >&, cosmo, std::vector<opa, std::allocator >, std::vector<flt, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator >)': /data2/programs/lephare_pp/LEPHARE-stable/source/onesource.cpp:1954: undefined reference to `std::filesystem::create_directory(std::filesystem::cxx11::path const&)' collect2: error: ld returned 1 exit status make: *** [Makefile:89: zphota] Error 1

Thanks a lot!

johannct commented 2 weeks ago

Hi, it looks like you need to add a flag in some distros : https://stackoverflow.com/questions/71548227/undefined-reference-to-stdfilesystem-cxx11 namely stdc++fs Can you make the change by hand and confirm that it solves the problem? thanks!

johannct commented 1 week ago

captured in the Known Issues section of the doc

Bovornpratch commented 1 week ago

Sorry for the late reply. I was able to compile it and was testing it to see if things were working as expected.

For the record, in case someone stumbles upon this. Here is what I did. I tried adding -lstdc++fs to the CFLAGS variable in the make file but that didn't help. After digging stackoverflow a bit I tried pointing the LIBS variable to point to the libstdc++fs.a library directly (LIBS=[path to lib]/libstdc++fs.a). This works. and the code compiled sucessfully.

Thanks for your Help!