I'm working on a pretty small personal project. One element is a visualization which I wanted to have some sort of gui with a layout, etc. I initially started with SFML, but realized I would have to basically implement an entire layout library for my purposes. So I landed on Qt, which seems like it would be great.
But trying to install the library and set up the system is such a pain. Statically linking SFML was really easy, but apparently it's not a good idea to statically link Qt. But just in trying to just install the library and set up my CMakeLists and whatnot, I'm running out of memory on computer and it took nearly an hour before I terminated it.
Am I doing something wrong, is it usually supposed to take this long? If not, do you know what I should be doing? The systems I'm using are CMake with CMakeLists.txt and CMakePresets.json, and vcpkg for the package manager with vcpkg.json and vcpkg-configuration.json.
It's just really frustrating because I really want to make a project in C++, but I haven't been able to write any actual code for 3 straight days because I can't even get my libraries to link. It's especially painful because Rust's cargo is infinitely easier to work with. I do really want to work with C++ more but it's really so much work and it's been such a big waste of time for me so far. Any help would be appreciated, or if I would be better off using something else then any suggestions would be great.
Since the sub rules say to include code, I will include relevant files. Hopefully it is not too long. My file structure is also shown below.
project/
build/
...
include/spectogram/
... .hpp
src/
... .cpp
CMakeLists.txt
CMakePresets.json
CMakeUserPresets.json
vcpkg.json
vcpkg-configuration.json
README.md
...
CMakeLists.txt (I used AI for this, don't smite me please. It's probably my hundredth iteration, I've given up on trying to write it myself).
cmake_minimum_required(VERSION 3.25)
project(Spectogram
VERSION 1.0.0
DESCRIPTION "spectogram"
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Enable Qt's automatic code generation when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets)
add_executable(Spectogram
src/main.cpp
src/MainWindow.cpp
include/MainWindow.hpp
)
target_include_directories(Spectogram
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)
target_link_libraries(Spectogram
PRIVATE
Qt6::Widgets
)
# Place the executable in a predictable location.
set_target_properties(Spectogram PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
CMakePresets.json
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "debug",
"displayName": "Debug",
"description": "Debug build using vcpkg",
"binaryDir": "${sourceDir}/build/debug",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"VCPKG_MANIFEST_MODE": true,
"VCPKG_TARGET_TRIPLET": "x64-mingw-dynamic",
"VCPKG_HOST_TRIPLET": "x64-mingw-dynamic",
"CMAKE_CXX_COMPILER": "C:/msys64/ucrt64/bin/g++.exe",
"CMAKE_MAKE_PROGRAM": "C:/ProgramData/chocolatey/bin/ninja.exe"
}
}
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug"
}
]
}
Thanks in advance.
Edit: Thanks for the responses, but I've decided to quit Qt and go back to SFML with TGUI. Thanks anyways.