#Need help adding a library (Qt6) to CMakeLists.txt
732 messages ยท Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
cmake_minimum_required(VERSION 3.28.0)
project(SimpleMusicPlayer2 VERSION 1.0.0)
add_executable(SimpleMusicPlayer2 main.cpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
```I have this so far
This is a screenshot of my root dir
this is the include folder
this is the lib folder
I'm having trouble adding Qt6 to CMake, so I can use it in main.c++
and the CMake documentation is a mess, I've read a bit and used ChatGPT to help
I just need to add Qt6
it's a local build, that I've split up into the include, lib, and bin folders
https://github.com/qt/qtbase - I downloaded the Qt6 source from here, and built it with CMake and Ninja
I hope that was the right library haha
did you run the install step of qt's cmake build?
that should have produced some cmake config files you can use to find_package qt in your project
it's in the instructions ๐
https://doc.qt.io/qt-6/windows-building.html#step-4-build-the-qt-library
mkdir qt6-build
cd qt6-build
C:\Qt\6.6.1\Src\configure.bat
cmake --build .
cmake --install .
did you delete the directory where you built qt?
unless you deleted other stuff, you should be able to move those things back
if you remember where they go ๐
I deleted the whole build
RIP
once you do, don't move stuff out of it
find_package(Qt6 REQUIRED COMPONENTS Widgets)
to find it, then link to the stuff you need like widgets
target_link_libraries(helloworld PRIVATE Qt6::Widgets)
what stuff do I move over from the build directory
nothing
the install step will put everything needed somewhere
probably C:\Qt or something
maybe C:\Program Files\Qt
do I just move the whole build to my project folder
nope
Qt is huge
you don't want to include hundreds of MB of binaries in your git project ๐
I think just the sources of Qt are like 700MB
I mean, they have a lot of GUI options
fair
if I shared the whole project, can other people build it without Qt being included, does CMake magically do something
if they have Qt installed
ok that's cool
find_package looks in a few default places
if they installed it elsewhere, they can also tell cmake to look there
how do I specify where it is, so it doesn't have to spend extra time looking everywhere?
oh nevermind that
how does it know what qt6 is
how does it know where to look
it looks in some places like C:\Program Files\
for a folder called Qt6
and variations
and somewhere in there it expects a file like Qt6-config.cmake
which tells it all about the thing
so I ust use find_package and it should include itself
yes, if it can find it in the places it looks
I will be back when I compile qt6
๐
it uses 100% cpu lol
feel free to ping me, I might not see it ๐
lol you typoed CMAKE_BUILD_TYPE but it had a fallback to Release anyway 
you wrote CNAJE_BUILD_TYPE
the install step will create that folder with the headers, libraries, cmake config files, everything needed to use it
(lag over 9,000%)
so if you wanted to archive this so you can move it to another machine or something, that would be just fine
after you have this, you don't need the build folder anymore
(but maybe wait until stuff works before you delete it
)
I like ultrakill, too 
you could do cmake --build build --parallel 4 or something to use fewer cores for building, but it'll take longer ๐
that will take hours lol
I think it's using 57 threads or something
or are cores what you call them
what CPU you got 
6 perf cores with 12 threads + 4 efficiency cores with 4 threads == 16 threads total
Completed : [1178/1896]
how'd you get all that
Intelยฎ Coreโข i7-12650H Processor (24M Cache, up to 4.70 GHz) quick reference with specifications, features, and technologies.
noice
by the way, I'm doing all this to recreate my first music player for fun
I can send it here
it's not made that good, buttons looks weird
_ _
and about ultrakill
does it have multiplayer, I only played the old pirated version
got up to the fast angel guy
forgot his name
in the fleshy looking place
_ _
Directory: C:\Users\jason\Downloads\qtbase-dev\build
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 5/01/2024 9:41 PM bin
d----- 5/01/2024 9:41 PM CMakeFiles
d----- 5/01/2024 9:27 PM config.tests
d----- 5/01/2024 9:28 PM doc
d----- 5/01/2024 9:28 PM include
d----- 5/01/2024 9:41 PM lib
d----- 5/01/2024 9:30 PM mkspecs
d----- 5/01/2024 9:28 PM modules
d----- 5/01/2024 9:28 PM plugins
d----- 5/01/2024 9:38 PM qmake
d----- 5/01/2024 9:28 PM src
-a---- 5/01/2024 9:41 PM 2563132 .ninja_deps
-a---- 5/01/2024 9:41 PM 281177 .ninja_log
-a---- 5/01/2024 9:28 PM 5732441 build.ninja
-a---- 5/01/2024 9:28 PM 147542 CMakeCache.txt
-a---- 5/01/2024 9:28 PM 55220 cmake_install.cmake
-a---- 5/01/2024 9:27 PM 56 config.redo.bat
-a---- 5/01/2024 9:28 PM 7806 config.summary
-a---- 5/01/2024 9:28 PM 345 CTestTestfile.cmake
Finished building
looks neat
k now the install step
done
CMake Error at CMakeLists.txt:12 (find_package):By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt6", but
CMake did not find one.
Could not find a package configuration file provided by "Qt6" with any of
the following names:
Qt6Config.cmake
qt6-config.cmake
Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR"
to a directory containing one of the above files. If "Qt6" provides a
separate development package or SDK, be sure it has been installed.CMake (find_package)
cmake_minimum_required(VERSION 3.28.0)
project(SimpleMusicPlayer2 VERSION 1.0.0)
add_executable(SimpleMusicPlayer2 main.cpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(helloworld PRIVATE Qt6::Widgets)
I tried this
and got that error
do I have to type the path manually
try adding -DCMAKE_PREFIX_PATH=C:/Qt to your cmake command line
or do you use some IDE or editor that calls cmake for your project
I just use vscode
when building
or installing
you could also try moving that Qt-6.8.0 folder to C:\Program Files, I guess
oh I should
it's one of the paths cmake will search for packages
I believe cmake searches in Program Files on windows by default
then it would "just work" hopefully
xD
DCMAKE_PREFIX_PATH=C:/Program Files/Qt
is it ok to have a space there
and what's the prefix for
does it just say to search there
the "prefix" is like the root where cmake will search for packages
can I specify multiple
is it ok to have a space in the name
might have to quote it, where are you specifying it
eh, no
thought so
inside the cmake file it would be set(VARIABLE "VALUE")
what's that
sets the variable named VARIABLE to the value VALUE
what variable do I set
CMAKE_PREFIX_PATH
(though normally, you wouldn't want to hard-code this in your cmake file)
DCMAKE_PREFIX_PATH="C:/Program Files/Qt"oh, I don't just put that in there
I have to set it
cmake_minimum_required(VERSION 3.28.0)
project(SimpleMusicPlayer2 VERSION 1.0.0)
add_executable(SimpleMusicPlayer2 main.cpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
DCMAKE_PREFIX_PATH="C:/Program Files/Qt"
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(helloworld PRIVATE Qt6::Widgets)
the -DNAME=VALUE syntax is for passing it on the cmake command line
set(CMAKE_PREFIX_PATH "C:/Program Files/Qt")
done that
the same error comes back
cmake_minimum_required(VERSION 3.28.0)
project(SimpleMusicPlayer2 VERSION 1.0.0)
add_executable(SimpleMusicPlayer2 main.cpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_PREFIX_PATH "C:/Program Files/Qt")
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(helloworld PRIVATE Qt6::Widgets)
try set(CMAKE_PREFIX_PATH "C:/Program Files/Qt/Qt-6.8.0/lib")
or, actually
search for files with the .cmake extension
there should be one called Qt6-config.cmake or Qt6Config.cmake
ok
need to find what directory that is in
in Qt
yeah
in the Qt-6.8.0 folder
you can do
set(Qt6_DIR "C:/Program Files/Qt/Qt-6.8.0/lib/cmake/Qt6")
instead
pointing it at the exact dir where it will find the file
should make it happy
should
:(
Exception has occurred: FATAL_ERROR
CMake Error at CMakeLists.txt:14 (find_package):
Found package configuration file:
C:/Program Files/Qt/Qt-6.8.0/lib/cmake/Qt6/Qt6Config.cmake
but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
FOUND. Reason given by package:
Failed to find required Qt component "Widgets".
Expected Config file at "C:/Program
Files/Qt/Qt-6.8.0/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake" exists
Configuring with --debug-find-pkg=Qt6Widgets might reveal details why the
package was not found.
Configuring with -DQT_DEBUG_FIND_PACKAGE=ON will print the values of some
of the path variables that find_package uses to try and find the package.
it's not happy
hey it found the file at-least
but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
FOUND. Reason given by package:
```It's not very smart either haha
that's weird
Expected Config file at "C:/Program
Files/Qt/Qt-6.8.0/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake" exists
so... it exists?
where's the problem 
xD
99.9% of the time is a waste of time
oh the best part
it's guaranteed
@lyric rain bad advertising award 2024
oh, maybe I need glasses
in vscode, if you go to preferences
then click the "workspace" button
then find the cmake.configureArgs setting
try adding the --debug-find-pkg=Qt6Widgets there cmake suggested
@lyric rain Has your question been resolved? If so, type !solved :)
yeet
wait actually why so few build steps?
also what is Qt 6.8, newest release is 6.6.1
found it on github
I'm building 6.6.1 rn
and it's 12000 build steps
yeah
did you clone and build that?
that might just be the qtbase library
yep
I downloaded as zip then built it
did I get the wrong file?
idk if they changed the organization of stuff
but as of 6.6.1 there are a ton of modules
qtbase is just one
where did you download yours from
that website is a pain to navigate
I probably got some spinoff downlaod
mine was 2.? GB when built
4 minutes
wow
lucky wifi moment
I'll delete this version of Qt so I can download the new one
12GB
WOW
the one I had was 2GB when built
the build folder contains a bunch of stuff you don't need to keep after it's done
oh
but yeah Qt is fairly... substantial ๐
can't wait for some new type of hard drive
I heard a company found a way to store terrabytes of data on glass plates as if they were Megabytes
using light
you know, if you used msys2 for example, you could just install a compiled version of qt
with a package manager
or you could sign up with Qt and use their installer to install a compiled version
what's mysys2
it's like a small linux like environment with bash and a package manager for installing compilers, libraries and other tools
sounds like mingw
yeah you can install mingw toolchains with it
but also a ton of libraries and tools built with mingw
like ffmpeg ,qt, whatever
will it be faster than building it
probably ๐
how do I install it with mysys2
pacman -S mingw-w64-x86_64-qt6-base does this look like the right command
installing
that installed crazy fast
it installed it into mysys2, as if it was integrated with it
how do I use it now?
so, ideally you would also install g++ in there
and use that compiler with your project as well
(so you might have to do the "scan for kits" thing again so VSCode finds the msys2 mingw)
and then it should just work
no setting of prefix path or qt6_dir needed
sweet
it still has the error after scanning
at the bottom you need to select the other compiler
where it says GCC 13.2 etc
if it found the msys install, you should have another one
ok
[
{
"name": "GCC 13.2.0 x86_64-w64-mingw32",
"compilers": {
"C": "C:\\w64devkit\\bin\\gcc.exe",
"CXX": "C:\\w64devkit\\bin\\g++.exe"
},
"isTrusted": true
}
]
do I add one
yeah, something like:
{
"name": "gcc x64",
"vendor": "gcc",
"keep": true,
"compilers": {
"CXX": "D:/Programs/msys2/mingw64/bin/g++.exe",
"C": "D:/Programs/msys2/mingw64/bin/gcc.exe"
},
"environmentVariables": {
"PATH": "${env:PATH};D:/Programs/msys2/mingw64/bin"
},
"isTrusted": true
},
adjust the paths
probably C:/msys64 for you instead
[
{
"name": "GCC 13.2.0 x86_64-w64-mingw32",
"compilers": {
"C": "C:\\w64devkit\\bin\\gcc.exe",
"CXX": "C:\\w64devkit\\bin\\g++.exe"
},
"isTrusted": true
},
{
"name": "w64devkit g++",
"compilers": {
"C": "C:\\w64devkit\\bin\\g++.exe",
"CXX": "C:\\w64devkit\\bin\\g++.exe"
},
"isTrusted": true
}
]
no ๐
no?
you can

I'll keep it, it has a bunch of useful commadns
like clear from linux
instead of cls
actually in the vscode settings, (user this time), you could add C:\msys64\mingw64 here and then the scan should find it automatically
without bin
ok
meh doesn't work for me anymore lol
._.
guess you'll have to edit the json after all
[
{
"name": "GCC 13.2.0 x86_64-w64-mingw32",
"compilers": {
"C": "C:\\w64devkit\\bin\\gcc.exe",
"CXX": "C:\\w64devkit\\bin\\g++.exe"
},
"isTrusted": true
},
{
"name": "GCC 13.2.0 x86_64-w64-mingw32 (mingw64)",
"compilers": {
"C": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"CXX": "C:\\msys64\\mingw64\\bin\\g++.exe"
},
"isTrusted": true,
"environmentVariables": {
"CMT_MINGW_PATH": "C:\\msys64\\mingw64\\bin"
}
}
]
the bottom one
it uses gcc for C
that's right
why not g++
because that's for C++ ๐
I'm using C++ though
cmake_minimum_required(VERSION 3.28.0)
project(SimpleMusicPlayer2 VERSION 1.0.0)
add_executable(SimpleMusicPlayer2 main.cpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(SimpleMusicPlayer2 PRIVATE Qt6::Widgets)
no error
how did a different compiler fix this
because in the same "root" as the compiler are all the libs you installed
what do you mean
all the mingw-w64-x86_64-* packages you install are under that C:\msys64\mingw64 "root"
in lib, bin, include etc.
oh
I installed Qt with it too
makes sense
#include <QApplication>
#include <QPushButton>
#include <QMessageBox>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
// Create a main window
QWidget mainWindow;
mainWindow.setWindowTitle("Simple Qt6 Application");
// Create a button
QPushButton button("Click me", &mainWindow);
// Connect the button click signal to a slot (function)
QObject::connect(&button, &QPushButton::clicked, [&]() {
// Show a message box when the button is clicked
QMessageBox::information(&mainWindow, "Button Clicked", "Hello, Qt World!");
});
// Set up the layout
QVBoxLayout layout(&mainWindow);
layout.addWidget(&button);
mainWindow.setLayout(&layout);
// Show the main window
mainWindow.show();
// Run the application event loop
return app.exec();
}
What do I need to do in CMakeLists.txt to include these?
what you have should be fine
those are all Widgets, I think?
maybe Qt6::GUI for QApplication
I can ask chatgpt
Qt docs for the class should say what module it's in
all widgets
QApplication: No such file or directory
all of them have this though
oh wow
reload and it's fixed
it has this issue though
it needs the dll to be in the same directory as the compiled executable
I think I need to compile it as a static or something, I heard this was what you do when you want to make it portable or something
I don't know how to do it though and it sounds harder than all of this
even when I copy all the dll files into the project, it gives me this
maybe 2 errors
or 1
how do I configure it for static
maybe I need to get a static build?
mingw-w64-x86_64-qt6-static
sounds like it might be static
should I install this
ima install it and see
yeah
only question is then what you need to do to get find_package to use those instead 
wdym
CMake Warning at C:/Program Files/CMake/share/cmake-3.28/Modules/CMakeFindDependencyMacro.cmake:76 (find_package):
[build] By not providing "FindQt6CoreTools.cmake" in CMAKE_MODULE_PATH this project
[build] has asked CMake to find a package configuration file provided by
[build] "Qt6CoreTools", but CMake did not find one.
[build]
[build] Could not find a package configuration file provided by "Qt6CoreTools"
[build] (requested version 6.6.1) with any of the following names:
[build]
[build] Qt6CoreToolsConfig.cmake
[build] qt6coretools-config.cmake
[build]
[build] Add the installation prefix of "Qt6CoreTools" to CMAKE_PREFIX_PATH or set
[build] "Qt6CoreTools_DIR" to a directory containing one of the above files. If
[build] "Qt6CoreTools" provides a separate development package or SDK, be sure it
[build] has been installed.
[build] Call Stack (most recent call first):
[build] C:/msys64/mingw64/qt6-static/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsDependencies.cmake:9 (find_dependency)
[build] C:/msys64/mingw64/qt6-static/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake:33 (include)
[build] C:/msys64/mingw64/qt6-static/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:65 (find_package)
[build] C:/msys64/mingw64/qt6-static/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:34 (_qt_internal_find_tool_dependencies)
[build] C:/msys64/mingw64/qt6-static/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include)
[build] C:/msys64/mingw64/qt6-static/lib/cmake/Qt6/Qt6Config.cmake:156 (find_package)
[build] CMakeLists.txt:12 (find_package)
oh
so much pain
should I go back to the other version?
or do I need a static build anyways
should I just compile one as static then use that instead?
how do you even compile something as static?
local/mingw-w64-x86_64-qt6-static 6.6.1-1
A cross-platform application and UI framework (mingw-w64)
```What I have
mingw-w64-ucrt-x86_64-qt6-tools
jason@JasonCoolLaptop MSYS ~
$ pacman -Ss qt6 static
clangarm64/mingw-w64-clang-aarch64-qt6-scxml 6.6.1-1 (mingw-w64-clang-aarch64-qt6)
Static and runtime integration of SCXML models into Qt6 code (mingw-w64)
clangarm64/mingw-w64-clang-aarch64-qt6-scxml-debug 6.6.1-1 (mingw-w64-clang-aarch64-qt6-debug)
Static and runtime integration of SCXML models into Qt6 code (mingw-w64)
clangarm64/mingw-w64-clang-aarch64-qt6-static 6.6.1-1
A cross-platform application and UI framework (mingw-w64)
mingw64/mingw-w64-x86_64-qt6-scxml 6.6.1-1 (mingw-w64-x86_64-qt6)
Static and runtime integration of SCXML models into Qt6 code (mingw-w64)
mingw64/mingw-w64-x86_64-qt6-scxml-debug 6.6.1-1 (mingw-w64-x86_64-qt6-debug)
Static and runtime integration of SCXML models into Qt6 code (mingw-w64)
mingw64/mingw-w64-x86_64-qt6-static 6.6.1-1
A cross-platform application and UI framework (mingw-w64)
ucrt64/mingw-w64-ucrt-x86_64-qt6-scxml 6.6.1-1 (mingw-w64-ucrt-x86_64-qt6)
Static and runtime integration of SCXML models into Qt6 code (mingw-w64)
ucrt64/mingw-w64-ucrt-x86_64-qt6-scxml-debug 6.6.1-1 (mingw-w64-ucrt-x86_64-qt6-debug)
Static and runtime integration of SCXML models into Qt6 code (mingw-w64)
ucrt64/mingw-w64-ucrt-x86_64-qt6-static 6.6.1-1
A cross-platform application and UI framework (mingw-w64)
clang64/mingw-w64-clang-x86_64-qt6-scxml 6.6.1-1 (mingw-w64-clang-x86_64-qt6)
Static and runtime integration of SCXML models into Qt6 code (mingw-w64)
clang64/mingw-w64-clang-x86_64-qt6-scxml-debug 6.6.1-1 (mingw-w64-clang-x86_64-qt6-debug)
Static and runtime integration of SCXML models into Qt6 code (mingw-w64)
clang64/mingw-w64-clang-x86_64-qt6-static 6.6.1-1
A cross-platform application and UI framework (mingw-w64)
jason@JasonCoolLaptop MSYS ~
```Unless one of these is the right version
try installing this
ok
maybe that has the tools you're missing with the -static package
how do you know if it's static
nevermind
the CoreTools thing is in the -static package
dunno why it doesn't find it
thanks
[main] Building folder: SimpleMusicPlayer2
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/jason/Desktop/SimpleMusicPlayer2/build --config Debug --target all --
[build] CMake Error at CMakeLists.txt:12 (find_package):
[build] By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has
[build] asked CMake to find a package configuration file provided by "Qt6", but
[build] CMake did not find one.
[build]
[build] Could not find a package configuration file provided by "Qt6" with any of
[build] the following names:
[build]
[build] Qt6Config.cmake
[build] qt6-config.cmake
[build]
[build] Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR"
[build] to a directory containing one of the above files. If "Qt6" provides a
[build] separate development package or SDK, be sure it has been installed.
[build]
[build]
[build] -- Configuring incomplete, errors occurred!
[build] [1/1 0% :: 0.004] Re-running CMake...
[build] FAILED: build.ninja
[build] "C:\Program Files\CMake\bin\cmake.exe" --regenerate-during-build -SC:\Users\jason\Desktop\SimpleMusicPlayer2 -BC:\Users\jason\Desktop\SimpleMusicPlayer2\build
[build] ninja: error: rebuilding 'build.ninja': subcommand failed
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/jason/Desktop/SimpleMusicPlayer2/build --config Debug --target all -- exited with code: 1
[driver] Build completed: 00:00:00.435
[build] Build finished with exit code 1
error maybe
cmake_minimum_required(VERSION 3.28.0)
project(SimpleMusicPlayer2 VERSION 1.0.0)
add_executable(SimpleMusicPlayer2 main.cpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(SimpleMusicPlayer2 PRIVATE Qt6::Widgets)
```no errors here
now it's not finding anything 
I installed it though
which one
you need one of the packages that provides the libs
and idk if you need the tools one
the tools package contains like the Qt form designer app
๐คท
it might cache downloads, too
error
again
Could not find a package configuration file provided by "Qt6CoreTools"
local/mingw-w64-ucrt-x86_64-qt6-base 6.6.1-3 (mingw-w64-ucrt-x86_64-qt6)
A cross-platform application and UI framework (mingw-w64)
local/mingw-w64-ucrt-x86_64-qt6-tools 6.6.1-1 (mingw-w64-ucrt-x86_64-qt6)
A cross-platform application and UI framework (Development Tools, QtHelp) (mingw-w64)
local/mingw-w64-x86_64-qt6-static 6.6.1-1
A cross-platform application and UI framework (mingw-w64)
I guess you need to set the prefix path again :v
try
set(CMAKE_PREFIX_PATH "C:/msys64/mingw64/qt6-static/lib/cmake")
I guess
ok
all the Qt6Whatever folders are under there
but if that doesn't work, idk, go back to using the shared libraries? ๐
Qt6Widgets
it doesn't work
I'm going to try compiling the build
it's going to take ages to even extract it
like an hour or so
then you still have to figure out how to configure a static build
and then you still have the same problem ๐
just use the shared libs that work
nothings worked really
the ones that worked needs an insane amount of dll's next to the exe
I won't stop until I find a way to make it static
I tried using the static ones
the first error it reports is some missing WrapZLIB package
which as far as I can tell doesn't exist 
if you use their configure script, it's -static
mkdir qt6-build
cd qt6-build
C:\Qt\6.6.1\Src\configure.bat -static
cmake --build .
cmake --install .
like that
but you need to do this before building 

I hope you still have enough free space
also get 7zip
if you want fast extraction of stuff ๐
how long could it possibly take to build 12000 files 
?
same idea
make some directory where all the build stuff will go
run those commands in there
point it at that configure.bat file
don't I configure it before I run the build
yesn't
yes
the script uses the current directory
not build
if you want it in build, you have to create the directory first
how
mkdir
oh I made build
mkdir qt6-build
cd qt6-build
C:\Qt\6.6.1\Src\configure.bat -static
cmake --build .
cmake --install .
it's in downloads for me
change the paths to whatever you want them to be
also you have to cd build if you want it to write into build
it doesn't really matter but it's easier to delete wrong stuff if it's in a separate directory ๐
so you don't have to extract it for half an hour again 
ima just leave it
I just need the build anyways
@granite rover what games do you play
currently sekiro
I got elden ring
souls like
whoops
I'll be back tomorrow when it's built
gotta sleep now
cya later
C:\Users\jason\Downloads\qt-everywhere-src-6.6.1\build>cmake --install .
-- Install configuration: "Release"
-- Up-to-date: C:/Qt/Qt-6.6.1/lib/cmake/Qt6BuildInternals/Qt6BuildInternalsConfig.cmake
-- Up-to-date: C:/Qt/Qt-6.6.1/lib/cmake/Qt6BuildInternals/Qt6BuildInternalsConfigVersion.cmake
-- Up-to-date: C:/Qt/Qt-6.6.1/lib/cmake/Qt6BuildInternals/Qt6BuildInternalsConfigVersionImpl.cmake
-- Up-to-date: C:/Qt/Qt-6.6.1/lib/cmake/Qt6BuildInternals/QtBuildInternalsExtra.cmake
-- Up-to-date: C:/Qt/Qt-6.6.1/lib/cmake/Qt6BuildInternals/QtStandaloneTestTemplateProject
-- Up-to-date: C:/Qt/Qt-6.6.1/lib/cmake/Qt6BuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt
-- Up-to-date: C:/Qt/Qt-6.6.1/lib/cmake/Qt6BuildInternals/QtStandaloneTestTemplateProject/Main.cmake
-- Up-to-date: C:/Qt/Qt-6.6.1/lib/cmake/Qt6/qt.toolchain.cmake
-- Up-to-date: C:/Qt/Qt-6.6.1/bin/qt-cmake.bat
-- Up-to-date: C:/Qt/Qt-6.6.1/bin/qt-cmake-create.bat
-- Up-to-date: C:/Qt/Qt-6.6.1/bin/qt-cmake-private.bat
-- Up-to-date: C:/Qt/Qt-6.6.1/bin/qt-configure-module.bat
-- Up-to-date: C:/Qt/Qt-6.6.1/bin/qt-cmake-standalone-test.bat
-- Up-to-date: C:/Qt/Qt-6.6.1/./bin/qt-cmake-private-install.cmake
-- Up-to-date: C:/Qt/Qt-6.6.1/bin/qt-internal-configure-tests.bat
-- Up-to-date: C:/Qt/Qt-6.6.1/./bin/android_emulator_launcher.sh
-- Up-to-date: C:/Qt/Qt-6.6.1/mkspecs/qconfig.pri
CMake Error at qtbase/cmake_install.cmake:94 (file):
file INSTALL cannot find
"C:/Users/jason/Downloads/qt-everywhere-src-6.6.1/build/qtbase/mkspecs/qmodule.pri":
No error.
Call Stack (most recent call first):
cmake_install.cmake:42 (include)
```got this
even in the official version, it can't find something
๐ฆ
I give up
no need to re-invent the wheel
ima just use the qt installer
re-inventing the wheel is a waste of time
instead of wasting time on doing something someone else has painfully done
just use their work
which is the qt installer
although this is unfiar. With python, you literately just have to do pip install pyqt
actually, this can be seen as an upgrade
in C++, I get to use an overkill fancy pancy installer to install my library!
would ya look at that
simplicity in it's finest
I just selected all the frameworks I wanted
like normal qt, android development, and some additional symbols for debugging (whatever they are)
time to sleep knowing everything will be easy lol
cya tomorrow
maybe
now the only question is which mingw their libs were compiled for ๐
it looks like i'm a bit late to the party, but if you're ok with qt5 you can just use a package manager. it looks like it's available as a vcpkg port. i have a template repo you can use to make a few edits to get that building pretty easily using vcpkg & cmake
qt5 is easier to get?
does it matter
how do I link it to this?
it's such a pain
won't find it no matter what
who woke up and decided to call Cmake useful if it can't even find a simple package
I DID IT
FUCK YES
@granite rover all that time making it work
I finally did it
but is it static :v
that's good
it can be a portable exe now
C:\Qt\6.6.1\mingw_64\lib\cmake I installed multiple versions, so I had to choose ming64 for windows
as long as you follow the license requirements
distributing an app that links qt statically means your app has to be open source ๐
well on linux for example, it would generally be frowned upon to ship your own copy of Qt instead of using the system installed one
if everyone did that (like people do on windows anyway
) you'd have tons of copies of Qt
did it say it was supposed to be static libs?
no :(
๐
why can't everything be static
oh
I got an idea
I make an installer
window wizard crap
but then I have to do that for other platforms like linux which I haven no idea how to
aaaaaaaaaaaaaaaaaaa
is there a way to specify the dll folder?
yesn't
so I don't have to messily add them to the same folder as the executable
windows looks on PATH for DLLs but that might not work for the plugin DLLs and other files
but qt has a tool windeployqt or something
to copy all the DLLs and other files needed by your app
how do I do it
I put the dll's in the build folder
for the exe
but build is a temp folder
that's bad
dll's aren't temp I don't think
they should be with the code
I wrote this cmake helper function once
# find windeployqt tool
if (WIN32)
find_program(WINDEPLOYQT windeployqt)
if (NOT WINDEPLOYQT)
message(WARNING "windeployqt not found, will not deploy Qt DLLs, plugins or configs!")
endif()
endif()
function(deploy_qt_deps)
set(options)
set(oneValueArgs TARGET)
set(multiValueArgs)
cmake_parse_arguments(QTDEPLOY_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
if (NOT QTDEPLOY_ARGS_TARGET)
message(FATAL_ERROR "TARGET argument required")
endif()
if (WIN32 AND WINDEPLOYQT)
# run windeployqt to gather required DLLs, plugins, qt.conf files etcetera.
add_custom_command(
TARGET ${QTDEPLOY_ARGS_TARGET}
POST_BUILD
COMMAND "${WINDEPLOYQT}" --dir "$<TARGET_FILE_DIR:${QTDEPLOY_ARGS_TARGET}>" "$<TARGET_FILE:${QTDEPLOY_ARGS_TARGET}>"
)
endif()
endfunction()
which you can then call like
deploy_qt_deps(TARGET YourProgram)
but it needs to find the windeployqt.exe on PATH or directories it checks by default
sick
I just paste it at the top of the script, then call it?
it's not found with the helper
# find windeployqt tool
if (WIN32)
find_program(WINDEPLOYQT windeployqt)
if (NOT WINDEPLOYQT)
message(WARNING "windeployqt not found, will not deploy Qt DLLs, plugins or configs!")
endif()
endif()
function(deploy_qt_deps)
set(options)
set(oneValueArgs TARGET)
set(multiValueArgs)
cmake_parse_arguments(QTDEPLOY_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
if (NOT QTDEPLOY_ARGS_TARGET)
message(FATAL_ERROR "TARGET argument required")
endif()
if (WIN32 AND WINDEPLOYQT)
# run windeployqt to gather required DLLs, plugins, qt.conf files etcetera.
add_custom_command(
TARGET ${QTDEPLOY_ARGS_TARGET}
POST_BUILD
COMMAND "${WINDEPLOYQT}" --dir "$<TARGET_FILE_DIR:${QTDEPLOY_ARGS_TARGET}>" "$<TARGET_FILE:${QTDEPLOY_ARGS_TARGET}>"
)
endif()
endfunction()
cmake_minimum_required(VERSION 3.28.0)
project(SimpleMusicPlayer2 VERSION 1.0.0)
add_executable(SimpleMusicPlayer2 main.cpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_PREFIX_PATH "C:/Qt/6.6.1/mingw_64/lib/cmake")
deploy_qt_deps(TARGET SimpleMusicPlayer2)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(SimpleMusicPlayer2 PRIVATE Qt6::Widgets)
```Do I need to change any paths?
if it says that it couldn't find it, you might have to do change
find_program(WINDEPLOYQT windeployqt)
to
find_program(WINDEPLOYQT windeployqt HINTS "P:/ath/to/folder/with/windeployqt")
ok
that's all that's found
maybe I didn't install it?
I'm starting to think qt is the worst library to ever exist
maybe I should try using https://www.wxwidgets.org/
it's similar to qt, just less shitty
I shouldn't of had to spend this much time on a single library. It's their fault for making everything over complicated with the build
I have to build it with mingw lol
first time
I thought cmake could build it, which is weird
Instead of using cmake to normally build it, I had to configure it, then use mingw-make to build it?
do you know why
also, is a shared library the library qt was using? And what I wanted was static? - to make it a portable exe
if you're cool with qt5 you can always try it out using vcpkg. here's a cmake + vcpkg template repo i use for most of my random projects: https://github.com/vorlac/cmake-vcpkg-project-template
you can click the "use this template" button on the main page and it'll copy the repo over to your github so you can use it as a base, then once you do that, clone it from your github to a local repo.
add qt5 (or qt5-base or whatever it's going to be) in this file: https://github.com/vorlac/cmake-vcpkg-project-template/blob/main/vcpkg.json#L8
then open the repo folder with vscode or vs2022 (if you use vs2022 open it as a folder)
in vscode: ctrl + shift + p to open the command menu, then find "cmake: delete cache and reconfigure" and run that
in vs2022: project -> "delete cache and reconfigure" (or just "configure")
you just need the C++ toolset and cmake extension for whichever of those you use
when the library is done building, towards the bottom of the cmake output it'll tell you which lines to add to cmakelists.txt to discover the package and to link it. it'll build as a static lib by default
the cmake output that you'll want to keep an eye out for should look something like this (except it'll just say qt5 instead of those libraries)...
it'll handle everything for you if the mingw build is still being a pain in the ass
these are all of the qt5 package names you can list in the vcpkg.json file:
is it hard to build other libraries too, or is it just qt
thanks
it's the same to build most other libraries with that setup
what's the difference between static and shared
it's usually 3 lines of code to add a library. one in vcpkg.json that lists the name of the library, one to discover the package in cmakelists.txt (i.e. find_package(qt5 CONFIG REQUIRED) and one more to link it (i.e. target_link_libraries(${PROJECT_NAME} PRIVATE qt5::qt5))
ok
static will link the qt libraries into your executable so you end up with 1 file and no external dll files. dynamic linkage will build qt5 as a dll then link your exe to that library dynamically so you'll need to have both files to run it.
if you want change it to use dynamic linkage instead, just update this line here: https://github.com/vorlac/cmake-vcpkg-project-template/blob/main/CMakePresets.json#L38
what is cmakepresets
just change that value to "x64-windows"
so that template is for building librares?
it stores compiler / options presets. a bunch of IDEs use them, but it also simplifies running cmake commands manually since it'll just grab all of the parameters needed for configuration and the build from there instead of having to pass them all in from the command line
in VS2022 the build presets just get pulled in so you can toggle between compilers or any other presets you add to that file from a menu like this:
then it just automates every cmake call so you don't really ever have to call it manually yourself. the IDE just does calls it for you instead
i barely use vs
I use vscode all the time
it's fast and has a nicer theme
lighter
I might use qt later on so I'll save the template
right now though, I'm going to use wxWidgets
I need to learn more about building source code
I barely understand anything with that right now
thanks for the help @thorny flicker @granite rover
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
you can use vscode for that template too
they both pretty much work the same for it
vs2022 is just a better IDE, but vscode will be perfectly fine if you'd prefer using that instead
just note that this means mot using mingw
i want to say for certain packages vcpkg will also setup and use mingw when it's required. i wouldn't be surprised if that's what it would end up doing for something like qt.