Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

如何将构建好的framelesshelper引入自己的项目 #309

Open
Mr-Second opened this issue Nov 2, 2023 · 2 comments
Open

如何将构建好的framelesshelper引入自己的项目 #309

Mr-Second opened this issue Nov 2, 2023 · 2 comments

Comments

@Mr-Second
Copy link

我对CMake不是很熟悉,我现在想把编译好的framelesshelper文件引入到我自己的项目中的步骤应该是怎样的呀?
这是我的编译过程:

cmake -DCMAKE_PREFIX_PATH=D:\Qt\6.6.0\msvc2019_64\ -DCMAKE_INSTALL_PREFIX=F:/Code_WorkSpace/QtWorkSpace/framelesshelper/build/install -DCMAKE_BUILD_TYPE=Release -GNinja .. -G "Visual Studio 17 2022"
 cmake --build . --parallel

然后得到这些文件:
1
然后把编译好的framelesshelper拷贝到自己项目文件夹
我自己的项目CMakeFiles.txt:

cmake_minimum_required(VERSION 3.16)

project(QMeeting VERSION 0.1 LANGUAGES CXX)


set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_PREFIX_PATH "D:/Qt/6.6.0/msvc2019_64")

find_package(Qt6 6.2 REQUIRED COMPONENTS Quick)


add_subdirectory(framelesshelper)

qt_add_executable(appQMeeting
    main.cpp
)

qt_add_qml_module(appQMeeting
    URI QMeeting
    VERSION 1.0
    QML_FILES App.qml
    RESOURCES images/meeting.png
    QML_FILES components/CustomWindow.qml
    QML_FILES components/MainWindow.qml
)

# 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.
set_target_properties(appQMeeting PROPERTIES
#    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appQMeeting
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_link_libraries(appQMeeting
    PRIVATE Qt6::Quick
    FramelessHelper::Core
    FramelessHelper::Quick
)

include(GNUInstallDirs)
install(TARGETS appQMeeting
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

项目文件结构:
5
然后我执行编译就会报下列错误:
2
4
3
不太明白为啥它报找不到这些DLL?😢

@ohPigFly
Copy link

ohPigFly commented Nov 3, 2023

image
你试一下是不是这里,把core,qml,加上去

@wangwenx190
Copy link
Owner

首先如果你只想包含FramelessHelper的SDK,那么就要用你install后的内容,我看你并没有执行install命令,你要在构建完成后调用cmake --install .,这样就会生成一个SDK文件夹,里面有你需要的所有东西。然后你运行报找不到dll的错误,是因为你没有设置PATH这个环境变量,这个跟cmake什么的一点关系都没有,你要手动去设置。我看你很不熟悉用VS去搞Qt开发,我建议你要么先去学习一下怎么用VS去开发Qt工程,要么去用QtCreator

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants