I use QT Creator 6.3 and I have created a library project and an application project. These are 2 separate projects. Now in my application project I want to add the library I created in library project. How do I do that? If i edit the cmake file it simply will not find the library, there is an option called add library if you right click on the project but this option is greyed out for me. I have no clue what is going on here. Can you help me?
If you want those two projects to remain independent, then you need to implement installing in the library project (see install(TARGETS)) and then from your application you can find_package after setting CMAKE_PREFIX_PATH to the installation prefix of the library. A simpler solution might be to create a project containing the two subprojects, with CMakeLists.txt one level above the two projects, and two calls to add_subdirectory. Then the targets will be known and you can just link to the library. If you have never written cmake code to install libraries including the generated Config.cmake file which allows to locate the installed library, prefer the second solution. Alternatively, KDAB gives online CMake trainings where we can explain all this in much more details 🙂. Next one is on Sep 6, see www.kdab.com/software-services/scheduled-training/introduction-to-cmake/
You can link to Qt statically if you first build Qt as a set of static libraries. A DLL is a dynamic library, you can't link statically to it. See the Qt documentation (section "Building Qt Sources") for how to build Qt yourself.
I use QT Creator 6.3 and I have created a library project and an application project. These are 2 separate projects. Now in my application project I want to add the library I created in library project. How do I do that? If i edit the cmake file it simply will not find the library, there is an option called add library if you right click on the project but this option is greyed out for me. I have no clue what is going on here. Can you help me?
If you want those two projects to remain independent, then you need to implement installing in the library project (see install(TARGETS)) and then from your application you can find_package after setting CMAKE_PREFIX_PATH to the installation prefix of the library. A simpler solution might be to create a project containing the two subprojects, with CMakeLists.txt one level above the two projects, and two calls to add_subdirectory. Then the targets will be known and you can just link to the library. If you have never written cmake code to install libraries including the generated Config.cmake file which allows to locate the installed library, prefer the second solution. Alternatively, KDAB gives online CMake trainings where we can explain all this in much more details 🙂. Next one is on Sep 6, see www.kdab.com/software-services/scheduled-training/introduction-to-cmake/
Can I link Qts dlls statically?
Same problem here, help
You can link to Qt statically if you first build Qt as a set of static libraries. A DLL is a dynamic library, you can't link statically to it. See the Qt documentation (section "Building Qt Sources") for how to build Qt yourself.