1

I want to build a qt app that links with shared libraries (as qt apps do by default). But qt always compiles the app as a shared library. I know that this is possible because I've found several Linux apps (not shared libraries) that links dynamically. For example, most of KDE applications are written in Qt, but are still applications, not shared libs. Is there a compiler/linker flag that allows me to build qt applications on Linux? No answer -static, please.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
  • probably this will solve your problem --> https://stackoverflow.com/questions/7626526/load-shared-library-by-path-at-runtime – user2760375 Jul 10 '18 at 21:09
  • Thanks for reply, but no. My app links well with dynamic libs, but qt compiles it as a shared library. As my problem is specific to Qt, I will edit the question. –  Jul 10 '18 at 21:13

1 Answers1

0

They are not shared libraries, but normal applications.

On modern GNU/Linux systems, programs are compiled as PIE (Position Indipendent Executable). This is done, for security reasons, to allow the text section of the program (i.e. the code) to be loaded at a new random address every time the program is run.

From an ELF/kernel perspective the process loading a PIE program is extremely similar to the process of loading a PIC shared library, so a PIE executable has ELF type ET_DYN, which is the one used by shared libraries.

For this reason, some programs, like file(1), will recognize them as shared libraries, but they are not shared libraries.

smeso
  • 4,165
  • 18
  • 27