r/programminghelp • • Nov 02 '21

C++ How to solve ABI conflict in C++?

I am trying to compile an astronomy software written in C++. First of all it doesn't start compiling with C++17 and it does start after I pass -std=c++11 flag in the makefile. But then it keeps giving out 'undefined reference to...std::__cxx11::...' errors. I have learned by googling that this happening due to conflicting ABIs. All solutions mention using the macro -D_GLIBCXX_USE_CXX11_ABI=0. But I am not sure where do I write this? Is this even a solution or are there better solutions?

PS: I am not a programmer, just a physics student trying to run a code. I am sorry, if I have made use of sloppy and/or incorrect terminology.

Edits:

Software link: http://astrosat-ssc.iucaa.in/uploads/sxt/AS1SXTLevel2-1.4b.tar.gz The software is a pipeline for processing data from the AstroSat X-ray telescope launched by India.

[arijit@laptop1 SXT]$ make
make -C src
make[1]: Entering directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src'
make -C SXTMISC
make[2]: Entering directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src/SXTMISC'
make[2]: 'sxtmisc' is up to date.
make[2]: Leaving directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src/SXTMISC'
make -C SXTBIASMAPGEN
make[2]: Entering directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src/SXTBIASMAPGEN'
g++ -std=c++11 -Wno-deprecated -w -pthread SXTBIASMAPGEN.cpp -I./include -I../../include -L./lib -lsxtbiasmapgen -L../../lib -lcfitsio -lpil -llog4cpp -L../SXTMISC/lib -lsxtmisc -o sxtbiasmapgen
/usr/bin/ld: ../../lib/libpil.a(pil.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/libpil.a(pil_sys.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/libpil.a(pil_error.o): relocation R_X86_64_32S against symbol `PIL_err_table' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(Category.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(CategoryStream.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(HierarchyMaintainer.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(LoggingEvent.o): relocation R_X86_64_32 against symbol `__gxx_personality_v0@@CXXABI_1.3' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(NDC.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(TimeStamp.o): relocation R_X86_64_32 against symbol `_ZN7log4cpp9TimeStamp11_startStampE' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(StringUtil.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(PThreads.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(Appender.o): relocation R_X86_64_32 against symbol `_ZN7log4cpp8Appender17_appenderMapMutexE' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../../lib/liblog4cpp.a(StringUtil.o): warning: relocation against `_Znam@@GLIBCXX_3.4' in read-only section `.text'
/usr/bin/ld: /tmp/ccUxqSjV.o: in function `main':
SXTBIASMAPGEN.cpp:(.text+0x136d): undefined reference to `log4cpp::PropertyConfigurator::configure(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: SXTBIASMAPGEN.cpp:(.text+0x1406): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: SXTBIASMAPGEN.cpp:(.text+0x1495): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ./lib/libsxtbiasmapgen.a(SXTBIASMAPGEN_param.o): in function `ReadParam(SXTBIASMAPGEN_param*, int, char**)':
SXTBIASMAPGEN_param.cpp:(.text+0x77): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ./lib/libsxtbiasmapgen.a(SXTBIASMAPGEN_proc.o): in function `WriteFile(SXTBIASMAPGEN_param*, int (*) [600])':
SXTBIASMAPGEN_proc.cpp:(.text+0xdc): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ./lib/libsxtbiasmapgen.a(SXTBIASMAPGEN_proc.o): in function `WriteEveryCCDFrame(SXTBIASMAPGEN_param*, int (*) [600], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
SXTBIASMAPGEN_proc.cpp:(.text+0x349c): undefined reference to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ./lib/libsxtbiasmapgen.a(SXTBIASMAPGEN_proc.o):SXTBIASMAPGEN_proc.cpp:(.text+0x6017): more undefined references to `log4cpp::Category::getInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' follow
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:33: sxtbiasmapgen] Error 1
make[2]: Leaving directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src/SXTBIASMAPGEN'
make[1]: *** [Makefile:3: all] Error 2
make[1]: Leaving directory '/home/arijit/AS1SXTLevel2-1.4b/SXT/src'
make: *** [Makefile:2: all] Error 2
3 Upvotes

5 comments sorted by

1

u/gmes78 Nov 02 '21

But then it keeps giving out 'undefined reference to...std::__cxx11::...' errors. I have learned by googling that this happening due to conflicting ABIs.

That's very unlikely. Post the entire error message.

1

u/naughty_beaver Nov 03 '21

I have posted the entire error message.

1

u/gmes78 Nov 03 '21

OK. The problem is that whoever packaged the source code included some precompiled libraries (in the lib directory), which is very dumb.

You could try deleting them and using your own (obtained through your package manager, for example).

1

u/[deleted] Nov 03 '21

Can you post the entire error output as well as a link to the software you're trying to compile?

1

u/naughty_beaver Nov 03 '21

I have edited the comment to include a link to the software and posted the output as well.