#Need help adding a library (Qt6) to CMakeLists.txt

732 messages ยท Page 1 of 1 (latest)

lyric rain
#

This is my first time using CMake for a project

royal treeBOT
#

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.

lyric rain
#
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

lyric rain
#

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

#

I hope that was the right library haha

granite rover
#

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

lyric rain
#

oh

#

no?

#

I didn't know that could be done

#

how do I run install?

granite rover
lyric rain
#

do I need to rebuild it?

granite rover
#

did you delete the directory where you built qt?

lyric rain
#

I moved the necessary files out of it

#

yeah

granite rover
#

unless you deleted other stuff, you should be able to move those things back

#

if you remember where they go ๐Ÿ˜„

lyric rain
#

I deleted the whole build

granite rover
#

RIP

lyric rain
#

I can rebuild it lol

#

it only takes 10 or so minutes

granite rover
#

once you do, don't move stuff out of it

lyric rain
#

after I run the install, what do I do with it?

#

to use it

granite rover
#
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)
lyric rain
#

what stuff do I move over from the build directory

granite rover
#

nothing

#

the install step will put everything needed somewhere

#

probably C:\Qt or something

#

maybe C:\Program Files\Qt

lyric rain
#

do I just move the whole build to my project folder

granite rover
#

nope

lyric rain
#

what if I wanted to include it in the project

#

for open source

granite rover
#

Qt is huge

#

you don't want to include hundreds of MB of binaries in your git project ๐Ÿ˜„

lyric rain
#

can a library really be that big???

#

wow

granite rover
#

I think just the sources of Qt are like 700MB

lyric rain
#

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

granite rover
#

if they have Qt installed

lyric rain
#

ok that's cool

granite rover
#

find_package looks in a few default places

#

if they installed it elsewhere, they can also tell cmake to look there

lyric rain
#

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

granite rover
#

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

lyric rain
#

so I ust use find_package and it should include itself

granite rover
#

yes, if it can find it in the places it looks

lyric rain
#

I will be back when I compile qt6

granite rover
#

๐Ÿ˜„

lyric rain
#

it uses 100% cpu lol

granite rover
#

feel free to ping me, I might not see it ๐Ÿ˜„

lyric rain
#

thanks

#

here we go

granite rover
#

lol you typoed CMAKE_BUILD_TYPE but it had a fallback to Release anyway yamikek

lyric rain
#

what do you mean

granite rover
#

you wrote CNAJE_BUILD_TYPE

lyric rain
#

haha this wasn't the building step

#

whoops

granite rover
#

but it's fine

#

:v

lyric rain
#

oh haha

#

XD

granite rover
#

ah see

lyric rain
#

ooh

#

that's neat

#

it tell you wherer it's installing

granite rover
#

the install step will create that folder with the headers, libraries, cmake config files, everything needed to use it

lyric rain
#

(lag over 9,000%)

granite rover
#

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 yamikek )

lyric rain
#

that is nasty

#

whoops

#

I'm lagging so badly

#

hard to type

granite rover
#

I like ultrakill, too yamikek

lyric rain
#

noice :doge:

#

who's yamikek

granite rover
#

you could do cmake --build build --parallel 4 or something to use fewer cores for building, but it'll take longer ๐Ÿ˜›

lyric rain
#

that will take hours lol

#

I think it's using 57 threads or something

#

or are cores what you call them

granite rover
#

what CPU you got thonk

lyric rain
lyric rain
granite rover
#

6 perf cores with 12 threads + 4 efficiency cores with 4 threads == 16 threads total

lyric rain
#

Completed : [1178/1896]

granite rover
#

and about 16 g++ processes

#

seems right

granite rover
lyric rain
#

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

granite rover
#

k now the install step

lyric rain
#

yikes no wonder

#

still less than unity lol

lyric rain
#
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

granite rover
#

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

lyric rain
#

I just use vscode

lyric rain
#

or installing

granite rover
#

no no

#

your project

#

not qt

lyric rain
#

oh

#

lol

#

what does prefix path do

granite rover
#

you could also try moving that Qt-6.8.0 folder to C:\Program Files, I guess

lyric rain
#

oh I should

granite rover
#

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

lyric rain
#

it's there now

#

whoops

#

I'm multitasking'

#

that was a video

#

im not playing it

granite rover
#

xD

lyric rain
#

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

granite rover
#

the "prefix" is like the root where cmake will search for packages

lyric rain
#

can I specify multiple

granite rover
#

yes

#

; separated

#

but you shouldn't need to for this

lyric rain
#

is it ok to have a space in the name

granite rover
lyric rain
#

ok

#

there's no cmake errors

#

will #includes work in the main.cpp now?

granite rover
#

eh, no

lyric rain
#

thought so

granite rover
#

inside the cmake file it would be set(VARIABLE "VALUE")

lyric rain
#

what's that

granite rover
#

sets the variable named VARIABLE to the value VALUE

lyric rain
#

what variable do I set

granite rover
#

CMAKE_PREFIX_PATH

#

(though normally, you wouldn't want to hard-code this in your cmake file)

lyric rain
#

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)
granite rover
#

the -DNAME=VALUE syntax is for passing it on the cmake command line

#
set(CMAKE_PREFIX_PATH "C:/Program Files/Qt")
lyric rain
#

done that

granite rover
#

ok, and?

#

cmake happy or not

lyric rain
#

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)
granite rover
#

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

lyric rain
#

ok

granite rover
#

need to find what directory that is in

lyric rain
#

in Qt

granite rover
#

yeah

lyric rain
#

oh any

#

ok

granite rover
#

in the Qt-6.8.0 folder

lyric rain
#

found it

granite rover
#

hm I feel like that should work

#

but ok

lyric rain
granite rover
#

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

lyric rain
#

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

granite rover
#

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 thonk

lyric rain
#

yes

#

where

#

oh I know what can *not find the problem

#

chatGPT

granite rover
#

xD

lyric rain
#

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

granite rover
#

not wrong

#

but not the problem ๐Ÿ˜„

lyric rain
#

that wasn't the problem

#

yeah

#

lol

#

cmake is as painful as tasks.json

granite rover
#

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

royal treeBOT
#

@lyric rain Has your question been resolved? If so, type !solved :)

lyric rain
#

yeet

granite rover
#

also what is Qt 6.8, newest release is 6.6.1

lyric rain
#

is that right

granite rover
#

not environment variables

#

configure arguments

lyric rain
granite rover
#

I'm building 6.6.1 rn

lyric rain
granite rover
#

and it's 12000 build steps

lyric rain
#

yeah

granite rover
#

that might just be the qtbase library

lyric rain
granite rover
#

yep

lyric rain
#

did I get the wrong file?

granite rover
#

idk if they changed the organization of stuff

#

but as of 6.6.1 there are a ton of modules

#

qtbase is just one

lyric rain
#

where did you download yours from

lyric rain
#

that website is a pain to navigate

granite rover
#

you download the zip that contains all the sources

#

as you can see it's 1.2GB lol

lyric rain
#

I probably got some spinoff downlaod

#

mine was 2.? GB when built

#

4 minutes

#

wow

#

lucky wifi moment

granite rover
#

and I'm only halfway done building yamikek

lyric rain
#

I'll delete this version of Qt so I can download the new one

lyric rain
#

WOW

#

the one I had was 2GB when built

granite rover
#

the build folder contains a bunch of stuff you don't need to keep after it's done

lyric rain
#

oh

granite rover
#

but yeah Qt is fairly... substantial ๐Ÿ˜„

lyric rain
#

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

granite rover
#

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

lyric rain
#

what's mysys2

granite rover
#

it's like a small linux like environment with bash and a package manager for installing compilers, libraries and other tools

lyric rain
#

sounds like mingw

granite rover
#

yeah you can install mingw toolchains with it

#

but also a ton of libraries and tools built with mingw

#

like ffmpeg ,qt, whatever

lyric rain
#

will it be faster than building it

granite rover
#

probably ๐Ÿ˜„

lyric rain
#

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?

granite rover
#

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

lyric rain
#

oh ok

#

I have g++ installed with mingw I think

#

somewhere else

lyric rain
#

it still has the error after scanning

granite rover
#

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

lyric rain
#

it can't find G++

#

I installed G++ to C:/wdevkit

granite rover
#

alright then do Ctrl+Shift+P "edit kits"

#

a json file should open

lyric rain
lyric rain
#
[
  {
    "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

granite rover
#

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

lyric rain
#
[
  {
    "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
  }
]
granite rover
#

no ๐Ÿ˜„

lyric rain
#

no?

granite rover
#

you want to use the msys2 mingw

#

that's how it "just works"

lyric rain
#

oh

#

I should install it there first

granite rover
#

pacman -S mingw-w64-x86_64-gcc

#

maybe also make or ninja

lyric rain
#

should I delete the dev kit in C

#

I only used the compilers in it

granite rover
#

you can

lyric rain
#

oh it has pkill

#

weird

#

on windows

#

what's that gui kill

granite rover
lyric rain
#

I'll keep it, it has a bunch of useful commadns

#

like clear from linux

#

instead of cls

granite rover
#

actually in the vscode settings, (user this time), you could add C:\msys64\mingw64 here and then the scan should find it automatically

lyric rain
#

I'll do that

#

do I do the bin folder

#

or will it looks all over it

granite rover
#

without bin

lyric rain
#

ok

granite rover
#

meh doesn't work for me anymore lol

#

._.

#

guess you'll have to edit the json after all

lyric rain
#
[
  {
    "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

granite rover
#

that's right

lyric rain
#

why not g++

granite rover
#

because that's for C++ ๐Ÿ˜„

lyric rain
#

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

granite rover
#

because in the same "root" as the compiler are all the libs you installed

lyric rain
#

what do you mean

granite rover
#

all the mingw-w64-x86_64-* packages you install are under that C:\msys64\mingw64 "root"

#

in lib, bin, include etc.

lyric rain
#

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?

granite rover
#

what you have should be fine

#

those are all Widgets, I think?

#

maybe Qt6::GUI for QApplication

lyric rain
#

I can ask chatgpt

granite rover
#

Qt docs for the class should say what module it's in

lyric rain
#

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

lyric rain
#

how do I configure it for static

#

maybe I need to get a static build?

#

mingw-w64-x86_64-qt6-static

granite rover
#

sounds like it might be static

lyric rain
#

ima install it and see

granite rover
#

yeah

#

only question is then what you need to do to get find_package to use those instead yamikek

lyric rain
#

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

granite rover
#

did you uninstall the other one?

#

or what

lyric rain
#

yeah

#

I can reinstall it

granite rover
#

this might only be the libraries

#

idk

#

so you might need both for libs + tools

lyric rain
#

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
granite rover
#

mingw-w64-ucrt-x86_64-qt6-tools

lyric rain
#
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
granite rover
#

try installing this

lyric rain
granite rover
#

maybe that has the tools you're missing with the -static package

lyric rain
#

how do you know if it's static

granite rover
#

nevermind

#

the CoreTools thing is in the -static package

#

dunno why it doesn't find it

lyric rain
#

what's rg do

#

does it look inside the package

#

like a search within a search

granite rover
#

pacman -Ql lists all the files in the package

#

rg just filters the output

lyric rain
#

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
granite rover
#

now it's not finding anything yamikek

lyric rain
#

I installed it though

granite rover
#

which one

lyric rain
#

I uninstalled the rest

granite rover
#

yeah no

#

this is just some executables

lyric rain
#

oh

#

I should of kept the last one

granite rover
#

you need one of the packages that provides the libs

#

and idk if you need the tools one

lyric rain
#

I'm installing it

#

I'll see if it works

granite rover
#

the tools package contains like the Qt form designer app

lyric rain
#

oh

#

the actual app

#

and it works?

granite rover
#

๐Ÿคท

lyric rain
#

it installed fast

#

but my wifi's on steroids today

granite rover
#

it might cache downloads, too

lyric rain
#

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)
granite rover
#

I guess you need to set the prefix path again :v

lyric rain
#

what was that

#

oh squiggle

#

I have no idea what I'm doing

granite rover
#

try

set(CMAKE_PREFIX_PATH "C:/msys64/mingw64/qt6-static/lib/cmake")

I guess

lyric rain
#

ok

granite rover
#

all the Qt6Whatever folders are under there

#

but if that doesn't work, idk, go back to using the shared libraries? ๐Ÿ’€

lyric rain
#

I dont't see Qwidgets

granite rover
#

Qt6Widgets

lyric rain
#

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

granite rover
#

then you still have to figure out how to configure a static build

#

and then you still have the same problem ๐Ÿ˜›

lyric rain
#

:(

#

"and they said CMake was easier"

#

nuh uh

granite rover
#

just use the shared libs that work

lyric rain
#

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

granite rover
#

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 yamikek

lyric rain
#

lol

#

imagine building this haha

#

RIP my computer

granite rover
#

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

lyric rain
#

thanks

#

I'll do that when it finished building

granite rover
#

but you need to do this before building thonk

lyric rain
#

tomato tomato

#

this feels like it's building

granite rover
#

I hope you still have enough free space

#

also get 7zip

#

if you want fast extraction of stuff ๐Ÿ˜„

lyric rain
#

oh it's fast?

#

finally

#

it's done

#

...extracting

granite rover
#

how long could it possibly take to build 12000 files yamikek

lyric rain
#

๐Ÿฆ“

#

C:\Qt\6.6.1\Src\configure.bat -static

#

how do I do this to the file I have

granite rover
#

?

lyric rain
#

configure it

granite rover
#

same idea

#

make some directory where all the build stuff will go

#

run those commands in there

#

point it at that configure.bat file

lyric rain
#

don't I configure it before I run the build

granite rover
#

yes

#

but you need to run it from the directory where all the stuff should go

lyric rain
#

configure --static then cmake --build ./build

#

that?

granite rover
#

yesn't

lyric rain
#

yes

granite rover
#

the script uses the current directory

#

not build

#

if you want it in build, you have to create the directory first

lyric rain
#

how

granite rover
#

mkdir

lyric rain
#

oh I made build

granite rover
#
mkdir qt6-build
cd qt6-build
C:\Qt\6.6.1\Src\configure.bat -static
cmake --build .
cmake --install .
lyric rain
#

it's in downloads for me

granite rover
#

change the paths to whatever you want them to be

lyric rain
#

I just did configure, but it looks like it's about to start building it

granite rover
#

eww

#

wait what

#

why are you doing it in qtbase ๐Ÿ˜„

lyric rain
#

...

#

qt-everywhere-src-6.6.1

#

crap

#

it's in qtbase

#

how did that happen

#

bruhj

granite rover
#

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 rolf

lyric rain
#

ima just leave it

#

I just need the build anyways

#

@granite rover what games do you play

granite rover
#

currently sekiro

lyric rain
#

I got elden ring

#

souls like

#

whoops

#

I'll be back tomorrow when it's built

#

gotta sleep now

#

cya later

lyric rain
#
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

granite rover
#

๐Ÿ˜ฆ

lyric rain
#

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

granite rover
#

now the only question is which mingw their libs were compiled for ๐Ÿ˜›

thorny flicker
#

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

lyric rain
#

qt5 is easier to get?

lyric rain
#

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

granite rover
#

but is it static :v

lyric rain
#

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

granite rover
#

as long as you follow the license requirements

lyric rain
#

I couldn't care less about legalities

#

lol

granite rover
#

distributing an app that links qt statically means your app has to be open source ๐Ÿ˜›

lyric rain
#

good

#

why is static bad though?

#

I like open source

granite rover
#

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

lyric rain
granite rover
#

if everyone did that (like people do on windows anyway yamikek ) you'd have tons of copies of Qt

lyric rain
#

noooooooo

#

it lied

#

whyyy

#

it's not static

#

bruh

#

all that work

granite rover
#

did it say it was supposed to be static libs?

lyric rain
#

no :(

granite rover
#

๐Ÿ˜„

lyric rain
#

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?

granite rover
#

yesn't

lyric rain
#

so I don't have to messily add them to the same folder as the executable

granite rover
#

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

lyric rain
#

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

granite rover
#

??

#

they need to be with the .exe

granite rover
# lyric rain how do I do it

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

lyric rain
#

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?
granite rover
#

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")
lyric rain
#

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

#

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

lyric rain
#

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

thorny flicker
#

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.

#

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:

lyric rain
#

is it hard to build other libraries too, or is it just qt

thorny flicker
#

it's the same to build most other libraries with that setup

lyric rain
#

what's the difference between static and shared

thorny flicker
#

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))

lyric rain
#

ok

thorny flicker
#

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.

lyric rain
#

what is cmakepresets

thorny flicker
#

just change that value to "x64-windows"

lyric rain
#

so that template is for building librares?

thorny flicker
#

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

lyric rain
#

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

royal treeBOT
#

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

thorny flicker
#

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

granite rover
#

just note that this means mot using mingw

thorny flicker
#

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.

granite rover
#

you can use a mingw triplet to build for mingw, too

#

I just don't have any idea how to do that properly

#

so I can't help with that yamikek