Build problem: can't find include file
-
Hello!
I created a customer widget.
In mainwindows.ui I created a QFrame as placeholder for this customer widget.
The class is called TabEditor and the include file is tabeditor.h.When compiling I get an error:
/home/atrink/src/testplatzhalter4/build/Desktop_Qt_6_7_0-Debug/testplatzhalter4_autogen/include/ui_mainwindow.h:23: Fehler: tabeditor.h: No such file or directory
In file included from /home/atrink/src/testplatzhalter4/mainwindow.cpp:2:
/home/atrink/src/testplatzhalter4/build/Desktop_Qt_6_7_0-Debug/testplatzhalter4_autogen/include/./ui_mainwindow.h:23:10: fatal error: tabeditor.h: No such file or directory
23 | #include <tabeditor.h>
| ^~~~~~~~~~~~~The strange thing is, on Windows it works. I get this error only in Linux (Fedora).
I also made a fresh installation via qt-unified-linux-x64-4.7.0-online.run.Any idea? Thanks in advance
-
@atrink said in Build problem: can't find include file:
#include <tabeditor.h>
You should include your own files inside
"..."
, not<...>
. So#include "tabeditor.h"
. Behaviour/search path may vary across platform/compiler. Does that make it work for you? -
@JonB
#include <tabeditor>
is part of file ui_mainwindow.h, which is autogenerated:Form generated from reading UI file 'mainwindow.ui'
Created by: Qt User Interface Compiler version 6.7.0
WARNING! All changes made in this file will be lost when recompiling UI file!Don't know how to test this.
br
-
bash:~/src/testplatzhalter4$ ls
build CMakeLists.txt CMakeLists.txt.user main.cpp mainwindow.cpp mainwindow.h mainwindow.ui tabeditor.cpp tabeditor.h tabeditor.uimainwindow.ui:
Press on QFrame, then "Als Platzhalter für benutzerdefinierte Klasse festlegen"Basisklasse: QFrame
Klassenname: TabEditorI also checked that upper and lowercase is correct. That's all I did.
I would like to attach my project here. How can I attach a (zip-)file?
Thanks!
-
cmake_minimum_required(VERSION 3.5)
project(testplatzhalter4 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)set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
tabeditor.h tabeditor.cpp tabeditor.ui
)if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(testplatzhalter4
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)Define target properties for Android with Qt 6 as:
set_property(TARGET testplatzhalter4 APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/android)
For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(testplatzhalter4 SHARED
${PROJECT_SOURCES}
)Define properties for Android with Qt 5 after find_package() calls as:
set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else() add_executable(testplatzhalter4 ${PROJECT_SOURCES} ) endif()
endif()
target_link_libraries(testplatzhalter4 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
If you are developing for iOS or macOS you should consider setting an
explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.testplatzhalter4)
endif()
set_target_properties(testplatzhalter4 PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)include(GNUInstallDirs)
install(TARGETS testplatzhalter4
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(testplatzhalter4)
endif() -
-
@atrink said in Build problem: can't find include file:
@JonB
#include <tabeditor>
is part of file ui_mainwindow.h, which is autogenerated:Fair enough!
include_directories(${CMAKE_SOURCE_DIR})
It is because of the
<...>
in the #include that this is required! -