neutronimaging / imagingsuite

Sources for imaging related tools
GNU General Public License v3.0
18 stars 11 forks source link

Undefined symbol when running MuhRec #674

Closed vlocateli closed 3 months ago

vlocateli commented 4 months ago

Hello, I'm having a problem when running MuhRec:

./MuhRec: symbol lookup error: ./MuhRec: undefined symbol: _Z12CheckFoldersRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb

I linked like the README said with patchelf command:

patchelf --set-rpath '$ORIGIN' *.so*

From what I've seen this is probably a CXX file being compile by a C compiler which demangles to:

undefined symbol: CheckFolders(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)

also, some tests are failing when running Ctest.

The following tests FAILED:
          4 - tkiplfilters (Failed)
          8 - tKIPL_IO (Failed)
         11 - tkiplbase (Failed)
         15 - tKiplMath (Failed)
         18 - tHistogram (Failed)
         19 - tImagingAlgorithms (Failed)
         20 - tImagingQAAlgorithms (Failed)
         21 - tReaderConfig (Failed)
         22 - tModuleConfig (Failed)
         23 - tReconConfig (Failed)
         24 - tFramework (Failed)
         27 - tStdPreprocModules (Failed)
Errors while running CTest

Thanks.

anderskaestner commented 4 months ago

The tests probably fail because they don't have test data. Please clone https://github.com/neutronimaging/TestData

damskii9992 commented 4 months ago

Your issue with CXX could be related to your version of the gcc compiler. Can you check if your gcc compiler has the "new" ABI libstdc++11 available and on by default? In contrast to the old ABI: libstdc++. The conan profile you use from the repo assumes that the new ABI is on by default. You might have to change a flag to enable this.

vlocateli commented 4 months ago

My libstdc++ is libstdc++.so.6. I made a simple C++ program:

#include <iostream>

int main(){
    std::cout << "hello" << std::endl; 
    return 0;
}

and used ldd i got:

linux-vdso.so.1
libstdc++.so.6
libc.so.6
libm.so.6
/lib64/ld-linux-x86-64.so.2

I need this flag?

-D_GLIBCXX_USE_CXX11_ABI=0
vlocateli commented 4 months ago

The tests probably fail because they don't have test data. Please clone https://github.com/neutronimaging/TestData

Ok, I will clone the new repo. I forgot to do it in the university machine. :/

damskii9992 commented 4 months ago

and used ldd i got:

linux-vdso.so.1
libstdc++.so.6
libc.so.6
libm.so.6
/lib64/ld-linux-x86-64.so.2

This does not really tell me whether or not your compiler uses the new ABI or old ABI by default. Can you run the following command in a terminal and report the output? gcc -v 2>&1 | sed -n 's/.*\(--with-default-libstdcxx-abi=new\).*/\1/p'

I need this flag?

-D_GLIBCXX_USE_CXX11_ABI=0

This flag forces the compiler to use the old ABI. If you set this flag, then you will also need to change the libcxx line in the conan profile to: compiler.libcxx=libstdc++ The important point is that your own compiler uses the same ABI as the consumed conan packages, whether that is the new ABI (libstdc++11) or the old ABI (libstdc++). I guess it is worth a try to see if it compiles and runs with the old ABI. Please ensure that you delete the build folder and re-run the conan install command to fetch new conan packages if you change the ABI.

damskii9992 commented 4 months ago

Also, please check your version of gcc by running: gcc --version If you're on kubuntu 22.04 the gcc compiler should be 11.4 by default, but if it is not then this also needs to be changed in the conan profile, as it is currently set to expect a gcc 11 compiler.

vlocateli commented 4 months ago

and used ldd i got:

linux-vdso.so.1
libstdc++.so.6
libc.so.6
libm.so.6
/lib64/ld-linux-x86-64.so.2

This does not really tell me whether or not your compiler uses the new ABI or old ABI by default. Can you run the following command in a terminal and report the output? gcc -v 2>&1 | sed -n 's/.*\(--with-default-libstdcxx-abi=new\).*/\1/p'

I need this flag?

-D_GLIBCXX_USE_CXX11_ABI=0

This flag forces the compiler to use the old ABI. If you set this flag, then you will also need to change the libcxx line in the conan profile to: compiler.libcxx=libstdc++ The important point is that your own compiler uses the same ABI as the consumed conan packages, whether that is the new ABI (libstdc++11) or the old ABI (libstdc++). I guess it is worth a try to see if it compiles and runs with the old ABI. Please ensure that you delete the build folder and re-run the conan install command to fetch new conan packages if you change the ABI.

I ran the first command and I got:

--with-default-libstdcxx-abi=new

My gcc version is 11.4 indeed.

damskii9992 commented 4 months ago

Hmm, that appears to be correct. Do you have multiple versions of GCC on your system? Or did you upgrade from an old version? Sometimes the compiler grabs the wrong/an old version of the libstdc++ library. Otherwise we will have to dig deeper to figure this out.

vlocateli commented 3 months ago

Ok. I could build it fine now. I have another problem. I'll open another issue.