Statically linking shared libraries for cross compilation
-
I am having problems with cross compiling Qt for an external embedded board. I managed to fix several missing dependencies by switching to static compilation, but doing this did not include libstdc++.so.6, which is causing problems still.
Here are things I have tried:
- Adding the -static flag while building Qt
- Adding the -static-runtime flag while building Qt
- Adding CONFIG += static to my .pro file
- Adding CONFIG += staticlib to my .pro file
- Adding QMAKE_LFLAGS += -static-libstdc++ to my .pro file
- Adding LIBS += -L/opt/Xilinx/SDK/2015.4/arm/lin/libc/usr/lib/ -lstdc++ to my .pro file
- Adding LIBS += /opt/Xilinx/SDK/2015.4/arm/lin/libc/usr/lib/libstdc++.a to my .pro file
None of these things have statically linked the library, when I try to use the executable on my target platform it still fails due to the missing .so
Can someone explain how to static link libstdc++.so.6 in a QtCreator project?
-
Hi,
You don't, you have to first compile libstdc++ statically before you can do that.
From the looks of it, it seems that your target sysroot is missing libraries. You should take the time to look into that.
-
Hi,
You don't, you have to first compile libstdc++ statically before you can do that.
From the looks of it, it seems that your target sysroot is missing libraries. You should take the time to look into that.
-
IIRC, if the linker finds both the static and dynamic version in the same folder, it will use the dynamic.
You can try to pass
-Bstatic -lstdc++
or use the full path. You'll have to modify the mkspec you are using to build Qt. You should even consider copying it and give it a new name so you ensure that you can still choose the original when needed. -
OK, I will try the -Bstatic suggestion.
Could you elaborate on what you mean by modify the mkspec?
Additionally, your other suggestion was to use the full path of the static library. The 7th thing I listed in my original post was to add: LIBS += /opt/Xilinx/SDK/2015.4/arm/lin/libc/usr/lib/libstdc++.a to my .pro file, is that not the correct syntax?
-
Take a looks at the
mkspecs
folder in Qt's sources.It's the set of configuration Qt uses.