I have boost 1.73 static libraries (.a) and RHEL devtoolset-10 installed,I do the following steps
scl enable devtoolset-10 bash
Check the LD_LIBRARY_PATH points to
/opt/rh/devtoolset-10/root/usr/lib64:/opt/rh/devtoolset-10/root/usr/lib:/opt/rh/devtoolset-10/root/usr/lib64/dyninst:/opt/rh/devtoolset-10/root/usr/lib/dyninst:/opt/rh/devtoolset-10/root/usr/lib64:/opt/rh/devtoolset-10/root/usr/lib
I set the CXX and CC to /opt/rh/devtoolset-10/root/bin/g++ and /opt/rh/devtoolset-10/root/bin/gcc respectively
This is snippet of my makefile
LPATH := -L/home/boost/lib/linux.2_6.x86_64 \
-L/opt/rh/devtoolset-10/root/bin/ \
-L/opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10 \
-L/opt/rh/devtoolset-10/root/usr/lib64
LFLAG := -lboost_filesystem -lboost_system -l:libstdc++.a -l:libgcc.a -static
.PHONY: all clean
all: $(EXE)
$(EXE): $(BUILTOBJ)
$(CXX) -DBOOST_NO_CXX11_SCOPED_ENUMS -Xlinker -Map=rhel.map $(LPATH) -o $@ $(BUILTOBJ) $(LFLAG)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) -DBOOST_NO_CXX11_SCOPED_ENUMS $(INCLUDES) -c $< -o $@
$(OBJ_DIR)/%.o: %.c
mkdir -p $(@D)
$(CC) $(INCLUDES) -c $< -o $@
Segmentation fault occurs at these three places..I got the boost functions that throw error ,these are
boost::filesystem::path src(sourcepath);
src.filename()
for(boost::filesystem::directory_iterator file(src); file!=boost::filesystem::directory_iterator(); ++file)
boost::filesystem::remove_all(sourcepath);
Also a snippet on my rhel.map file
(boost::filesystem::path::operator/=(boost::filesystem::path const&)) /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/libstdc++.a(bad_alloc.o) /home/boost/lib/linux.2_6.x86_64/libboost_filesystem.a(directory.o) (typeinfo for std::bad_alloc) /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/libstdc++.a(class_type_info.o) obj/Action.o (vtable for __cxxabiv1::__class_type_info) /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/libstdc++.a(del_op.o) /home/boost/lib/linux.2_6.x86_64/libboost_filesystem.a(exception.o) (operator delete(void*)) /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/libstdc++.a(del_ops.o) obj/Action.o (operator delete(void*, unsigned long)) /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/libstdc++.a(del_opv.o) obj/CZip.o (operator delete) /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/libstdc++.a(dyncast.o) obj/Action.o (__dynamic_cast) /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/libstdc++.a(eh_alloc.o) obj/Action.o (__cxa_allocate_exception)
Also if I use the -g flag I get this and similar DWARF debug error
DWARF error: could not find variable specification at offset 23b28
The code works fine in ubuntu which has gcc 9.3.1 but in rhel-7 with devtoolset it gives segmentation fault(core dumped)
Is there some error with my linking?