Static version does not include external targetted libs
-
Hello gurus,
so I use static version,
all works fine, app exe is generated with all standard and qt dlls so its fine to open in any windows machine.However the external libraries i link against the project are NOT included in this...
cmake:
... set_target_properties(${PROJECT} PROPERTIES WIN32_EXECUTABLE TRUE INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/nwrfcsdk/include" ) ... set(SAPNWRFC_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/nwrfcsdk/lib") if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(SAPNWRFC_LIB_FILES sapnwrfc.lib libsapucum.lib) else() set(SAPNWRFC_LIB_FILES -lsapnwrfc -lsapucum) endif() target_link_directories(${PROJECT} PRIVATE ${SAPNWRFC_LIB_DIR}) ... target_link_libraries(${PROJECT} PRIVATE Qt6::Quick PRIVATE Qt6::Gui PRIVATE ${SAPNWRFC_LIB_FILES} ) ... install(TARGETS ${PROJECT} BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
of course on my pc all works fine as i have this include folder set in PATH variable, however on another PC where these libraries are missing the app does not work
do i somehow need those libs (dlls) which i target/include against the project also set to be staticaly build in the project?
-
Hello gurus,
so I use static version,
all works fine, app exe is generated with all standard and qt dlls so its fine to open in any windows machine.However the external libraries i link against the project are NOT included in this...
cmake:
... set_target_properties(${PROJECT} PROPERTIES WIN32_EXECUTABLE TRUE INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/nwrfcsdk/include" ) ... set(SAPNWRFC_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/nwrfcsdk/lib") if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(SAPNWRFC_LIB_FILES sapnwrfc.lib libsapucum.lib) else() set(SAPNWRFC_LIB_FILES -lsapnwrfc -lsapucum) endif() target_link_directories(${PROJECT} PRIVATE ${SAPNWRFC_LIB_DIR}) ... target_link_libraries(${PROJECT} PRIVATE Qt6::Quick PRIVATE Qt6::Gui PRIVATE ${SAPNWRFC_LIB_FILES} ) ... install(TARGETS ${PROJECT} BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
of course on my pc all works fine as i have this include folder set in PATH variable, however on another PC where these libraries are missing the app does not work
do i somehow need those libs (dlls) which i target/include against the project also set to be staticaly build in the project?
@shokarta said in Static version does not include external targetted libs:
all works fine, app exe is generated with all standard and qt dlls
I'm not sure I understand what you're writing.
Do you mean you link your app statically against static Qt libs?
Are those not "included" libs also static libs? Everything needs to be static if you really want to have a single exe with everything included. -
@shokarta said in Static version does not include external targetted libs:
all works fine, app exe is generated with all standard and qt dlls
I'm not sure I understand what you're writing.
Do you mean you link your app statically against static Qt libs?
Are those not "included" libs also static libs? Everything needs to be static if you really want to have a single exe with everything included.@jsulm all QT libs and System libs ar eincluded in the exe file...
only those in /nwrfcsdk/lib/ are not included...There are bunch of *.dll files, couple *lib files and one *.pdb file,
and in the folder /nwrfcsdk/include/ there are only *.h files,
therefore I dont know how to find out if those libs are static as well -
@jsulm all QT libs and System libs ar eincluded in the exe file...
only those in /nwrfcsdk/lib/ are not included...There are bunch of *.dll files, couple *lib files and one *.pdb file,
and in the folder /nwrfcsdk/include/ there are only *.h files,
therefore I dont know how to find out if those libs are static as well@shokarta *.lib could be static libs (if Microsoft compiler was used), but they also can be the files needed to link against shared libs. So, I can't tell you for sure whether these libs are shared or static (but most probably shared).
-
You seem to be confused and are confusing everybody else as well. You either link statically OR you have DLLs. DLLs is the part that is called dynamic linking instead of static linking.
If you haven't compiled the Qt libraries yourself, Qt is linked dynamically and you need to provide the corresponding DLLs.
The same goes for other libraries. If those have DLLs you need to dynamically link those. (Dynamic linking actually refers to the OS having a dynamic linker which will load the DLLs every time you launch your app exe.) Still, DLLs normally have a corresponding .lib file. The .lib file just contains all the function names provided by the DLL. The linker (the one you are using during compilation) then knows that these functions are in fact not missing, but are also not linked into the app exe. As long as you can successfully compile and link your app you most likely did everything right. Windows also has a special feature that header files can list which libraries to link so these will link automatically (the corresponding .lib file for either a DLL or a real static library).
I am not familiar with Qt and CMake, so I am not sure what exactly
install
does in your CMake script. However, there is a Qt tool called windeployqt which will gather the necessary DLLs for deployment. -
You seem to be confused and are confusing everybody else as well. You either link statically OR you have DLLs. DLLs is the part that is called dynamic linking instead of static linking.
If you haven't compiled the Qt libraries yourself, Qt is linked dynamically and you need to provide the corresponding DLLs.
The same goes for other libraries. If those have DLLs you need to dynamically link those. (Dynamic linking actually refers to the OS having a dynamic linker which will load the DLLs every time you launch your app exe.) Still, DLLs normally have a corresponding .lib file. The .lib file just contains all the function names provided by the DLL. The linker (the one you are using during compilation) then knows that these functions are in fact not missing, but are also not linked into the app exe. As long as you can successfully compile and link your app you most likely did everything right. Windows also has a special feature that header files can list which libraries to link so these will link automatically (the corresponding .lib file for either a DLL or a real static library).
I am not familiar with Qt and CMake, so I am not sure what exactly
install
does in your CMake script. However, there is a Qt tool called windeployqt which will gather the necessary DLLs for deployment.@SimonSchroeder Thank you for quite well corresponding explanation!
tho from your reply, I dont realy get if you somewhere explain me that I can or cant link those dlls staticaly like all the other QT and System dlls into one big exe file containing all...
when building static app, it works very vell for all those QT and System libs... so i realy have only one big EXE file...
tho these external libs are just not included... but as far as i copy them manualy to the folder where the built app is, then all works fine...- unfortunatelly providing those DLLs is against the licence of the provider of this external libs, so I real ymust find a way how to protect them and not expose them
Therefore, can you recommend any way of doing that?
-
Just as I said, you cannot link DLLs statically (DLL stands for Dynamic Link Library and as the name suggests they are linked dynamically and never statically).
Why it does seem to work for you with Qt might have different reasons. You might have the Qt DLL directory in your PATH environment variable so that they are found by Windows. On another computer that does not have them installed it would not work. Or somehow you do have a static version of Qt that you are linking against. You can use tools like Dependency Walker (I think there is a newer tool replacing it) to figure out which DLLs your exe is looking for.
As you cannot statically link DLLs you might only try to obfuscate their existence. One way (which I don't know much about) would be to embed the DLLs as a resource into the exe (via a .qrc file). Then, the DLLs needs to be explicitly loaded during startup. It seems like Qt has just the thing for you: https://doc.qt.io/qt-6/qlibrary.html . I would expect that QLibrary could work with resource file paths to load the DLL (something like ":/external/myprivate.dll")
-
Just as I said, you cannot link DLLs statically (DLL stands for Dynamic Link Library and as the name suggests they are linked dynamically and never statically).
Why it does seem to work for you with Qt might have different reasons. You might have the Qt DLL directory in your PATH environment variable so that they are found by Windows. On another computer that does not have them installed it would not work. Or somehow you do have a static version of Qt that you are linking against. You can use tools like Dependency Walker (I think there is a newer tool replacing it) to figure out which DLLs your exe is looking for.
As you cannot statically link DLLs you might only try to obfuscate their existence. One way (which I don't know much about) would be to embed the DLLs as a resource into the exe (via a .qrc file). Then, the DLLs needs to be explicitly loaded during startup. It seems like Qt has just the thing for you: https://doc.qt.io/qt-6/qlibrary.html . I would expect that QLibrary could work with resource file paths to load the DLL (something like ":/external/myprivate.dll")
@SimonSchroeder but i also have the LIB files... whic could mean they might be static... is there a way to confirm that?
-
@SimonSchroeder but i also have the LIB files... whic could mean they might be static... is there a way to confirm that?
@shokarta said in Static version does not include external targetted libs:
but i also have the LIB files... whic could mean they might be static... is there a way to confirm that?
There is no static lib until you compiled Qt statically by yourself. And those static libs would be much larger than the dlls.
-
@shokarta said in Static version does not include external targetted libs:
but i also have the LIB files... whic could mean they might be static... is there a way to confirm that?
There is no static lib until you compiled Qt statically by yourself. And those static libs would be much larger than the dlls.
-
There is no static lib until you compiled Qt statically by yourself.
but I have QT static version build from source myself.
or you mean compiling those libs myself?@shokarta said in Static version does not include external targetted libs:
but I have QT static version build from source myself
If so then there will be no dlls around in the build folder. Same goes for some external libs.
Don't understand the static hype though...
-
@shokarta said in Static version does not include external targetted libs:
but I have QT static version build from source myself.
This explains why you don't need the Qt DLLs. (Very few people actually try to compile a static version of Qt because it makes it harder to comply with the LGPL.)
@shokarta said in Static version does not include external targetted libs:
but i also have the LIB files... whic could mean they might be static... is there a way to confirm that?
I am not really an expert in this. My best guess is to use
dumpbin
orlib
(Microsoft tools shipped with their compiler). Hopefully the symbols state if they are for a DLL or static lib.