我克隆了https://github.com/juce-framework/JUCE
我首先取消注释find_package(JUCE)
在/GuiApp'
CMakeList.txt。
然后我跑了cmake .. . -B cmake-build-dir -D JUCE_BUILD_EXAMPLES=ON
在顶级目录中。
它说:
-- Checking for modules 'webkit2gtk-4.0;gtk+-x11-3.0'
-- No package 'webkit2gtk-4.0' found
-- No package 'gtk+-x11-3.0' found
-- Checking for module 'alsa'
-- No package 'alsa' found
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
CMake Error at examples/CMake/GuiApp/CMakeLists.txt:27 (find_package):
Could not find a package configuration file provided by "JUCE" with any of
the following names:
JUCEConfig.cmake
juce-config.cmake
Add the installation prefix of "JUCE" to CMAKE_PREFIX_PATH or set
"JUCE_DIR" to a directory containing one of the above files. If "JUCE"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
我试图找到JUCEConfig.cmake在哪里
/work/juce/temp/JUCE/build$ find . -name JUCEConfig.cmake
./cmake-build-dir/tools/JUCEConfig.cmake
我该如何将此路径放入 CMAKE_PREFIX_PATHS 中?
最佳答案
克隆此存储库:https://github.com/juce-framework/JUCE
alsa
和 webkit2gtk
是必需的依赖项,但我的计算机中的 Ubuntu 18.04 上没有这些依赖项。您可能也必须按如下方式安装:
sudo apt install libwebkit2gtk-4.0-dev libasound2-dev
在此存储库的 examples/CMake
文件夹中,有一个名为 GuiApp
的文件夹。
要使用 JUCE/CMake 构建新的 GUI 应用程序项目,请执行以下操作(从头开始):
将
GuiApp
文件夹复制到新位置。在您复制的
GuiApp
的 CMakeLists.txt 中,替换添加子目录(JUCE)
与
add_subdirectory("<path_to_JUCE_cloned_repository>" JUCE)
将路径替换为系统上 JUCE 存储库的真实位置。
从您复制的
GuiApp
文件夹中运行cmake . -B cmake-build-dir
以上命令将创建一个名为cmake-build-dir
的构建树文件夹
cmake --build cmake-build-dir
以上命令将构建 cmake-build-dir 文件夹中的所有目标。
成功构建后,您可以通过进入以下目录来运行可执行文件:
cmake-build-dir/GuiAppExample_artefacts/
并发出./Gui\App\Example
。这是生成的默认可执行文件的名称。
关于c++ - 如何编译并运行一个hello world JUCE程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64317833/