Dont know how to build QuaZip. Please help.
-
So i've got ZLib build and linked to my projekt, but i cant get quazip to be build.
I tried:mkdir build cd build cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=C:\Users\Musik\QtLibraryBuilds\QuaZipLibrary
but there i get the error:
C:\Users\Musik\Desktop\quazip\quazip-master\quazip\build>cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=C:\Users\Musik\QtLibraryBuilds\QuaZipLibrary -- Building for: Visual Studio 17 2022 CMake Warning (dev) at CMakeLists.txt:1 (project): cmake_minimum_required() should be called prior to this top-level project() call. Please see the cmake-commands(7) manual for usage documentation of both commands. This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning at CMakeLists.txt:1 (project): VERSION keyword not followed by a value or was followed by a value that expanded to nothing. CMake Error at CMakeLists.txt:1 (project): VERSION not allowed unless CMP0048 is set to NEW -- Configuring incomplete, errors occurred!
.
.
.
.
.
Additionally here is my CMake file where i included the paths to my zlib files:cmake_minimum_required(VERSION 3.5) project(ZlibTest VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) include_directories("C:/Users/Musik/QtLibraryBuilds/ZlibLibrary/include") link_directories("C:/Users/Musik/QtLibraryBuilds/ZlibLibrary/lib") set(PROJECT_SOURCES main.cpp MainWindow.cpp MainWindow.h MainWindow.ui ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(ZlibTest MANUAL_FINALIZATION ${PROJECT_SOURCES} ) else() if(ANDROID) add_library(ZlibTest SHARED ${PROJECT_SOURCES} ) else() add_executable(ZlibTest ${PROJECT_SOURCES} ) endif() endif()
-
@StudentScripter The complaint is about something in the Quazip CMakelist.txt file, probably
C:\Users\Musik\Desktop\quazip\quazip-master\quazip\CmakeList.txt
, not your ZlibTest project.What version of CMake are you using?
Are you sure you have a fresh clone of Quazip master? Builds fine here on Linux.
Have you tried any of the tagged release branches instead of the dev version?
What are the first 10 to 20 lines of the CMakeLists.txt? -
The error says that one of the
CMakeLists.txt
files might be malformed, so I would check that.If this is the project that you were trying to build, then that one built and installed out of the box for me, so if there is an error in one of the
CMakeLists.txt
files, it's probably in one of yours.Also, this particular error doesn't seem to be related to Qt at all.
-
@veryqtperson Hi thank you very much for your response! <3
Yes, this is the exact project i try to build, but i just can't get it to work. I tried building it on 2 differents systems windows 10 and Arch Linux but now i always get this error or an error that qt6compact wasn't found somehow. Could you may explain to me step by step how you build the project successfully? That would be a real help as maybe im doing something wrong but just don't notice.
-
Well, to be entirely honest, it didn't build exactly out of the box, I had to tweak the Qt discovery a bit in the main project file:
diff --git a/CMakeLists.txt b/CMakeLists.txt index 113f6e0..47bc4ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,19 +33,13 @@ option(QUAZIP_FORCE_FETCH_LIBS "Enables fetching third-party libraries always" O # We search quietly for Qt6, Qt5 and Qt4 in that order. # Qt6 and Qt5 provide config files for CMake. # Qt4 relies on `FindQt4.cmake`. -find_package( - QT NAMES Qt6 Qt5 - QUIET COMPONENTS Core -) -if (NOT QT_FOUND) - find_package(Qt4 QUIET COMPONENTS QtCore) - if (Qt4_FOUND) - set(QT_VERSION_MAJOR 4) - else() - # If neither 6, 5 nor 4 are found, we default to 5. - # The setup will fail further down. - set(QT_VERSION_MAJOR 5) - endif() +find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) +if (Qt${QT_VERSION_MAJOR}_FOUND) + get_filename_component(QT_HOME "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE) + message(STATUS "Found Qt ${QT_VERSION}: ${QT_HOME}") +else() + message(FATAL_ERROR "Couldn't find Qt") endif() set(QUAZIP_QT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (4, 5 or 6), defaults to ${QT_VERSION_MAJOR}")
But anyway, that isn't related to the error you got, so I didn't think it was worth mentioning.
And then here's how I built and installed the project:
$ cd /path/to/quazip $ mkdir build && cd $_ $ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="../install" \ -DCMAKE_PREFIX_PATH="/path/to/qt" \ .. $ cmake --build . --target install
If anything, I used Qt 6.5.1 and CMake 3.27.8 on Mac OS 13.6.3.
-
@veryqtperson Well so i had to give a lot more information but your hint solved the qt6 problem. But now i get another error where i don't know what it means and how to fix?
First i passed:cmake -S .. -B . -DCMAKE_INSTALL_PREFIX="..C:/Users/Musik/QtLibraryBuilds/QuaZipLibrary" -DCMAKE_PREFIX_PATH="C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\lib\cmake"
than 2nd i entered : "$cmake --build . --target install" in the console.
than i got the error:C:\Users\Musik\Desktop\quazip\quazip-master\build>cmake --build . --target install MSBuild version 17.6.3+07e294721 for .NET Framework 1>Checking Build System Automatic MOC for target bzip2 Building Custom Rule C:/Users/Musik/Desktop/quazip/quazip-master/CMakeLists.txt mocs_compilation_Debug.cpp blocksort.c bzlib.c compress.c crctable.c decompress.c huffman.c randtable.c Code wird generiert... bzip2.vcxproj -> C:\Users\Musik\Desktop\quazip\quazip-master\build\Debug\bzip2d.lib Automatic MOC for target QuaZip Building Custom Rule C:/Users/Musik/Desktop/quazip/quazip-master/quazip/CMakeLists.txt mocs_compilation_Debug.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] JlCompress.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] qioapi.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quaadler32.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quachecksum32.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quacrc32.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quagzipfile.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quaziodevice.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quazip.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quazipdir.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quazipfile.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quazipfileinfo.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] quazipnewinfo.cpp C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore/qcompilerdetection.h(1220,1): fatal error C1189: #error: "Q t requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." [C:\Users\Musik\Desktop\quazip\quazip-master\build\quazip\QuaZip.vcxproj] Code wird generiert...
-
Looks like you need to enforce C++17 standard with
CMAKE_CXX_STANDARD
(and, of course, use a C++17-compliant compiler). -
@veryqtperson Hm but i don't understand that i've been using mingw for building all my projects so far in qt6 but never had issues. Which one would you recommend and how do i exactly set the standard to CMAKE_CXX_STANDARD? Where do i have to add that?
Also thanks again mate, really carried me trough this problem till now. Can't explain how frustrated i was the last days as i've read to official documentation multiple times and nothing worked. :)
-
In short, you would just add the following right after
project()
in yourCMakeLists.txt
:set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED YES)
Recent versions of MinGW should be C++17-compliant, so you can probably continue using that, although on Windows I'd recommend using MSVC or maybe Clang. On GNU/Linux the most common choice would be GCC or yet again Clang.
-
-
-
-