static compilation with sonames without specifying it
Solved
Qt Creator and other tools
-
Hi all,
I am experiencing a strange behavior. I am compiling a library without passing any static / staticlib option, but apparently it gets statically compiled somehow.
It correctly generates a .so file (I'm on Linux), but when I check it with ldd I see: "statically linked
" as output.I printed what is written in CONFIG and everything seems correct:
lex yacc debug exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin file_copies qmake_use qt warn_on release link_prl incremental shared plugin_manifest linux unix posix gcc qtc_run debug qml_debug qtc_run c++11 console
If I add other similar libraries and try to link them, I cannot be able to create dynamic libraries in any way.
This is the code:
QT -= gui TEMPLATE = lib DEFINES += MY_FIRST_LIBRARY CONFIG += c++11 DESTDIR = ../lib MOC_DIR = ../build OBJECTS_DIR = ../build TARGET = my_first DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ first_class.cpp HEADERS += \ first_class.h \ my_first_global.h \ # Default rules for deployment. unix { target.path = /usr/lib } !isEmpty(target.path): INSTALLS += target
What's going on in your opinion? any hint on how to debug it ?
Cheers
[EDIT 1]
Some more info: the generated Makefile has following flags:CFLAGS = -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC $(DEFINES) CXXFLAGS = -pipe -O2 -std=gnu++1z -Wall -Wextra -D_REENTRANT -fPIC $(DEFINES) LINK = g++ LFLAGS = -Wl,-O1 -Wl,-rpath,/home/genner/Qt/6.3.0/gcc_64/lib -Wl,-rpath-link,/home/genner/Qt/6.3.0/gcc_64/lib -shared -Wl,-soname,libmy_first.so.1 LIBS = $(SUBLIBS) /home/genner/Qt/6.3.0/gcc_64/lib/libQt6Gui.so /home/genner/Qt/6.3.0/gcc_64/lib/libQt6Core.so -lpthread -lGL
EDIT 2:
The file command tells me this:libmy_first.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=20250f39bd468b237bfcaac47960d8381f1e5ebe, with debug_info, not stripped
Again, ldd tells me instead:
statically linked