c++ - 如何编译并运行一个hello world JUCE程序?

标签 c++ linux cmake juce

我克隆了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

alsawebkit2gtk 是必需的依赖项,但我的计算机中的 Ubuntu 18.04 上没有这些依赖项。您可能也必须按如下方式安装:

sudo apt install libwebkit2gtk-4.0-dev libasound2-dev

在此存储库的 examples/CMake 文件夹中,有一个名为 GuiApp 的文件夹。

要使用 JUCE/CMake 构建新的 GUI 应用程序项目,请执行以下操作(从头开始):

  1. GuiApp 文件夹复制到新位置。

  2. 在您复制的 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。这是生成的默认可执行文件的名称。

    信用:https://forum.juce.com/u/reuk/summary

    关于c++ - 如何编译并运行一个hello world JUCE程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64317833/

    相关文章:

    linux - 漏洞 : Varnish 4 install on CentOS 7 (systemctl)

    linux - 通过单个命令行操作确定操作系统

    visual-studio-2010 - CMake 配置失败。 "cl.exe is not able to compile a simple test program"

    cmake - 如何手动将 CMake 路径变量设置为 NOTFOUND?

    c++ - OpenCV 3 中未在此范围内声明消息 "‘CV_SHAPE_ELLIPSE’

    c++ - 对齐int的多线程读写

    c++ - 需要有关类(class)的帮助

    C++ BWAPI异常访问冲突

    mysql - Debian 安装 MySQL 特定版本不可用

    cmake - 使用 CMake,如何在 gtest_discover_tests --gtest_list_tests 调用上设置环境属性?