- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 StackOverflow、Conan 和 CMake 的新手。
我正在尝试使用 CMake 构建一个依赖于 Qt 的 hello world 程序。我已经从公共(public)存储库 cmake-hello-world 克隆了它并编译成功。
现在,我正在尝试conanize
这个项目,并且我已经安装了Qt/5.9@bincrafters/stable
jfrog-bintray组件可以在 bintray
上轻松获得,并更改了 CMakelist.txt。
这是我的柯南简介:
cat ~/.conan/profiles/default
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=5
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
CMakeList.txt:
cmake_minimum_required(VERSION 3.5)
project(helloworld)
# If conan is being used, configure CMake to use conan for dependencies.
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
# Find includes in the build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Turn on automatic invocation of the MOC, UIC & RCC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# There may be a way to tell up front if Qt5 is going to be found, but I haven't found
# a foolproof way to do it yet, so settle for the default error message for now.
#if(NOT CMAKE_PREFIX_PATH AND NOT Qt5Widgets_DIR)
# message(WARNING "CMAKE_PREFIX_PATH is not defined, so find_package may not work.
Set the CMAKE_PREFIX_PATH "
# "environment variable to the install prefix of Qt 5, either on the command line as "
# "-DCMAKE_PREFIX_PATH=\"path/to/Qt5/lib/cmake\" or with set(CMAKE_PREFIX_PATH path/to/Qt5/lib/cmake)")
#endif(NOT CMAKE_PREFIX_PATH AND NOT Qt5Widgets_DIR)
# Add a compiler flag
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# Make this a GUI application on Windows
if(WIN32)
set(CMAKE_WIN32_EXECUTABLE ON)
endif()
# Find the QtWidgets library
find_package(Qt5 REQUIRED COMPONENTS Widgets)
# Tell CMake to create the helloworld executable
add_executable(helloworld main.cpp mainwindow.cpp mainwindow.ui resources.qrc)
# Add the Qt5 Widgets for linking
target_link_libraries(helloworld ${CONAN_LIBS})
从目录的根目录,我运行以下命令:
mkdir build
cd build
conan install .. --build missing
cmake ..
make
我收到以下错误:
[ 16%] Automatic moc, uic and rcc for target helloworld
[ 16%] Built target helloworld_automoc
[ 33%] Building CXX object CMakeFiles/helloworld.dir/main.cpp.o
In file included from /home/ram2020/temp/temp/working_qt_tar/Qt-CMake-HelloWorld/main.cpp:1:0:
/home/ram2020/temp/temp/working_qt_tar/Qt-CMake-HelloWorld/mainwindow.h:4:23: fatal error: QMainWindow: No such file or directory
compilation terminated.
CMakeFiles/helloworld.dir/build.make:62: recipe for target 'CMakeFiles/helloworld.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/helloworld.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/helloworld.dir/all' failed
make[1]: *** [CMakeFiles/helloworld.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
我在网上找不到太多帮助。请帮忙
最佳答案
我的解决方案比之前建议的解决方案稍微简单一些,但更重要的是,这不需要在您的 cmake 文件中包含 conan 特定条目,使其可移植。
conanfile.py
from conans import ConanFile
class TestbedConan(ConanFile):
name = "Testbed"
description = "Testbed"
license = "None"
url = "None"
settings = "os", "arch", "compiler", "build_type"
generators = [
"cmake_paths",
]
requires = [
"Qt/5.15.2"
]
CMakeLists.txt
cmake_minimum_required(VERSION 3.21.0)
project(helloworld VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
add_executable(helloworld
main.cpp
)
target_link_libraries(helloworld Qt::Widgets)
然后,您只需运行以下命令即可构建您的项目:
conan install -pr my_profile -if build .
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=conan_paths.cmake -Bbuild
cmake --build build
关于c++ - cmake、conan 和 qt hello world 项目构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60442347/
我尝试创建 conan boost 包裹图书馆。 我从 https://github.com/conan-io/conan-center-index/tree/master/recipes/boost
我们可以在 conan 中使用介子构建系统。但是我找不到任何关于如何在 meson.build 中添加 conan 包作为依赖项的文档。在cmake中非常简单,我们可以简单地使用conan_cmake
我有一个使用箭头和 Parquet 的项目。我下载并构建了所需的库,然后成功构建了我的库。现在我想迁移它以使用 conan,以简化构建过程。 我面临的问题是,大多数(如果不是全部)箭头的预构建二进制文
我有一个项目,我正在尝试使用 conan 作为包管理器。 该项目使用了大量的库,其中大部分是自给自足的。但是,其中一些依赖于另一个库。 举一个具体的例子,假设我们有一个项目 P,它需要库 A 和 B。
我有一组第三方二进制文件,我正试图将其放入柯南包中。二进制文件位于构建配置的文件夹中:Linux32、Win32、Win64、Win32。 我已经能够使用以下 conanfile.py 为 Win64
我正在使用 Jetbrains CLion 2019.3、MinGW 8.1 以及 Conan C/C++ Package Manager 1.21.1< 开发一个小型 C 可执行项目.我正在刷新有关
内容: 当我遇到一些问题时,我试图在gitlab管道上构建我的项目。在AWS的管道中运行gitlab-ci.yml时,在两个测试部分中,其中一个在conan安装步骤中失败。 成功的部分: - cona
对于本地缓存中的某个包 P,如何获取包 P 的配方(conanfile.py)? 例如,我们以一个名为的 conan 包为例: zlib/1.2.11@conan/stable 我可以从 conan-
假设我有一个库作为包上传到 conan 中,它使用 OpenGL,因此与 CMakeLists.txt 中的 GL 链接。库的用户是否需要再次明确链接到 GL? conan 是否提供了一种方法来跟踪它
通常 Conan包仅包含构建工件,如 *.dll、*.lib、*.pdb、*.so、 *.a、*.dylib 文件以及给定 C 或 C++ 库的 header 。然而,有时当您调试使用库的代码时,能够
我正在考虑开始使用 Conan用于管理我的 C++ 项目的第三方依赖项的包管理器,但我找不到如何仅链接到 Conan 包中的某些库。我正在使用 CMake作为构建系统,我正在使用 Conan 多配置
我运行:conan install Boost/1.64.0@conan/stable,但它失败了。 输出: C:\temp>conan install Boost/1.64.0@conan/stab
我写我的宠物项目。起初,它是基于 cmake 的,我从控制台设置了 qt 库的路径,例如cmake -DPATH_TO_QT:STRING=/home/user/Qt/5.11.1/gcc_64/变量
我们的 Jenkins 管道将有不同的并发作业运行 conan install 和 conan export-pkg 更新本地缓存。 我们目前在/home/jenkins/conan 中为 jenki
JFrog 的 Artifactory OSS 网页使它看起来像是 OSS 的一部分 https://www.jfrog.com/open-source/#conan .我正在 Docker 容器中试
我一直在为个人项目学习柯南,但我有一个问题,通过查看文档和示例无法回答。 Conan 的“配置文件”和 CMake 之间似乎缺乏交互,很尴尬。我的意思是:有许多不同的构建参数必须手动保持同步 - 使用
我正在使用 conan 包管理器为项目安装我的依赖项。该项目只需要所有boost库的boost系统,因为我只使用asio和beast。 但是,柯南安装了 boost 的每个部分,这是不可取的。如果我通
我正在尝试使用以下 conanfile.txt 文件安装 boost: [requires] cryptopp/8.2.0@bincrafters/stable boost/1.64.0@conan/
我经常看到很多 conanfile.py 并且它们都有类似的东西 from conans import ConanFile, CMake, tools 但我找不到 conans python 注册表中
我正在编写为 rabbitmq-c 创建包的配方图书馆。当选中其 CMake 脚本中的 ENABLE_SSL_SUPPORT 选项时,其构建需要 OpenSSL 库。 如提供的屏幕路径所示,libea
我是一名优秀的程序员,十分优秀!