I have been trying for a few days to get to Qt and I’m honestly having a lot of troubles, even putting files in directories/compiling it is pretty mysterious to me…
I am currently facing a problem where whenever I try to compile I will get this undefined reference for some reason.
The cmakelists should be correct, it looks something like that:
set(SOURCES
all the source files
set(UI_FILES
all the ui files
)
qt6_wrap_ui(UI_HEADERS ${UI_FILES})
include_directories(
all the directories with a .hpp in them
)
add_executable(Project WIN32
${SOURCES}
${UI_FILES}
${UI_HEADERS}
)
target_link_libraries(Project PRIVATE Qt6::Widgets)
Honestly, I tried everything I could think of/find on the net.
The file tree is pretty basic, I got a dir for src(source files), include(all the include files) and a gui(for the ui files). Each of the directories has subdirectories that correspond to the different aspects of the projects (cpp files for the qt are in a different subDir that ones working on the backend).
When putting the .ui file in the gui dir, I even used set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/gui)
to specify where to look for it and target_include_directories(Project PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/gui)
and I would still get that undefined reference.
Literally the only way I have to make it compile and run is to put the .cpp, .hpp and .ui files in the same subdirectory and add all that to the set(SOURCES)
which is like the absolute grossest way to do that in my opinion.
Any help appreciated…
1