I'm q newbie and i searched for the solution across the web making some "minor" progress but i'm pretty sure that i'm do things wrongly and there are very few video and tutorial about that, or maybe i didn't find it?
I'm experimenting with Qt Creator 15.0.1 adn Qt 6.6.3 writing some c++ qml project to learn this world a little bit, i'm using Linux Mint.
Now i'm trying to use the OpenXLSX library and following the official GitHub i "simply" need to "[...] add the OpenXLSX folder as a subdirectory to your own project [...] add the OpenXLSX folder as a subdirectory to the source tree of your own project". But i'm not sure how to do it properly.
I've done some test and managed to made the library work 2 times,
in the first attempt i added the header and the source file from the folder directly to the test project. With this method i had to edit every #include in all the source and header of the OpenXLSX library to make it work to point to the exact file... Worked well, no red error or warning mark but i think this is not the right way to do it.
So i tried to "add an existing project" pointing to the library cmakelists file. This one worked quite well and to make it work i simply added to my cmakelists file this code
target_link_libraries(appTest
PRIVATE Qt6::Quick OpenXLSX::OpenXLSX
)
#and
add_subdirectory(OpenXLSX)
This one worked, compiling and running well, but i got a lot yellow mark issue warning for "implicit conversion change signedness" "[-Wsign conversion] [-Wshorten-64-to-32] or [-Wdefaulted-function-deleted]
searched a lot on the web, someone suggest to use an "add library" command in qt creator but i can't find this voice in any of the menu.
What are the proper way to add this Library (and i suppose every other library i need) to an existing cmake project? THIS answer is 15 years old so i think that things are changed in the mean time and also other answer reefer to .pro file and "add library" voice that i don't seems to have in my Qt Creator.
I'm q newbie and i searched for the solution across the web making some "minor" progress but i'm pretty sure that i'm do things wrongly and there are very few video and tutorial about that, or maybe i didn't find it?
I'm experimenting with Qt Creator 15.0.1 adn Qt 6.6.3 writing some c++ qml project to learn this world a little bit, i'm using Linux Mint.
Now i'm trying to use the OpenXLSX library and following the official GitHub i "simply" need to "[...] add the OpenXLSX folder as a subdirectory to your own project [...] add the OpenXLSX folder as a subdirectory to the source tree of your own project". But i'm not sure how to do it properly.
I've done some test and managed to made the library work 2 times,
in the first attempt i added the header and the source file from the folder directly to the test project. With this method i had to edit every #include in all the source and header of the OpenXLSX library to make it work to point to the exact file... Worked well, no red error or warning mark but i think this is not the right way to do it.
So i tried to "add an existing project" pointing to the library cmakelists file. This one worked quite well and to make it work i simply added to my cmakelists file this code
target_link_libraries(appTest
PRIVATE Qt6::Quick OpenXLSX::OpenXLSX
)
#and
add_subdirectory(OpenXLSX)
This one worked, compiling and running well, but i got a lot yellow mark issue warning for "implicit conversion change signedness" "[-Wsign conversion] [-Wshorten-64-to-32] or [-Wdefaulted-function-deleted]
searched a lot on the web, someone suggest to use an "add library" command in qt creator but i can't find this voice in any of the menu.
What are the proper way to add this Library (and i suppose every other library i need) to an existing cmake project? THIS answer is 15 years old so i think that things are changed in the mean time and also other answer reefer to .pro file and "add library" voice that i don't seems to have in my Qt Creator.
Share Improve this question edited Apr 2 at 5:26 hyde 62.9k22 gold badges125 silver badges179 bronze badges asked Mar 22 at 12:33 MorenoMoreno 234 bronze badges 7 | Show 2 more comments2 Answers
Reset to default 0It is quite common that library header files trigger warnings. This is usually ok for system headers which are supplied with the compiler. For 3rd party libraries, it tells either of you using untested platform, of sloppy coding where the library developer does not care about warnings, or even of bugs.
You need to mark the include directories of that library as system include directory, using SYSTEM
flag in target_include_directories
Example adapted from this discussion, it should be something like this:
target_include_directories(appTest
SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/OpenXLSX/include
)
Another solution is to fork the library in GitHub, fix the warnings, and use your own fork. BSD-3 license should make forking and modifying non-problematic even for commercial/proprietary code. If you can be bothered, doing this with otherwise minimal changes, then creating a pull request for the upstream to take in your fixes, is highly recommended, as that is how open source software improves.
I want to reply to my own question just to update this post.
Sorry if i'm writing only after many days of silence, i readed all the suggestion and i want to say thanks to everyone!
I've experimented further with the integration of the library (and with many other things), i successfully used "Method 2" but i like to maintain my project as clean as possible so i didn't like that my folder/file tree was filled by numerous header and source file.
I ended up compiling the library into a shared library .so in my case and use it in my project in a much cleaner way (imho) basically using only dll and header file.
Warning keep appearing but for now it's fine like this.
std::size_t
to anint
or something like that. You ask about several questions at the same time, please edit and focus on one of them. – Friedrich Commented Mar 22 at 16:44CMakelists.text
in the question, as well as minimal "hello world"main.cpp
to reproduce the warnings or other problems. Also add the compile output from Qt Creator. It's good idea to add-v
to build tool options in Qt Creator Project view - Build Steps - Tool Arguments, so CMake gives that option to Ninja (probably the same with Make). This not very many lines, so doing this should not be any problem. – hyde Commented Apr 2 at 5:28