Cmake找到的Assimp Is不

发布于 2025-02-03 01:38:33 字数 1663 浏览 4 评论 0原文

在说什么之前:是的,我在此询问此处之前搜索了很长时间,因此99%的解决方案对我来说其他类似问题的解决方案对我不起作用。

我有一个使用以下库的OpenGL应用程序:

  • glfw
  • imgui
  • glad
  • STB
  • assimp assimp
  • glm
  • filebrowser(对话框iMgui的扩展程序)

所有这些库都位于一个名为“外部”的文件夹中,每个库中的每个库中的dir中的每个库。 此外,GLFW,ASSIMP,GLM是我的存储库的git子模型,因此当我用Git Clone克隆回购时,它们会下载。

您可以更好地了解项目的结构,以查看我的 git repo

我的想法是使用add_subdirectories与他们自己的cmakelists进行编译,而我的主要内容如下:

cmake_minimum_required(VERSION 3.21.3)

project(Reskinner)

set(CMAKE_CXX_STANDARD 17)     
set(CMAKE_VERBOSE_MAKEFILE ON)

add_executable(${PROJECT_NAME} Main.cpp)

add_subdirectory(external/glfw)
add_subdirectory(external/assimp)
add_subdirectory(external/glad)
add_subdirectory(external/imgui)
add_subdirectory(external/stb)
add_subdirectory(external/glm)
add_subdirectory(external/FileBrowser)
add_subdirectory(src)

find_package(OpenGL REQUIRED)

target_include_directories(${PROJECT_NAME}
    PUBLIC external/glfw/include
    PUBLIC external/assimp/include
    PUBLIC external/glm
    PUBLIC external
    PUBLIC src
)

target_link_libraries(${PROJECT_NAME} glfw glad imgui stb glm Engine assimp FileBrowser)

该项目是在Windows上使用Visual Studio开发的,我想在Linux上编译它而不使用VisualStudio。 cmake不会给我任何错误,但是当我运行make命令时,它给了我这个错误:

#include< assimp/quaternion.h>这个名称没有文件或目录。

就像我没有将Assimp包含在CMAKE中的文件夹(但我确实如此)一样。

您是否知道如何使它起作用?我想制作一个bash脚本来安装所有所需的依赖项和工具,例如xorg-dev,build-extental,git,cmake,make等。因此,如果使用某些bash命令进行了任何简单的修复,对我来说还可以。

Before saying anything: Yes, I googled and searched for a long time before asking this here so 99% the solution of other similar questions doesn't work for me.

I have an opengl application that uses the following libraries:

  • glfw
  • imgui
  • glad
  • stb
  • assimp
  • glm
  • filebrowser (an extension of imgui for dialog boxes)

all these libraries are in a folder called external each one in its dir.
Moreover, glfw, assimp, glm are git submodules of my repo so they're downloaded when i clone my repo with git clone --recursive mygitrepo.

You can have a better understanding of the structure of the project looking at my git repo.

My idea was to use the add_subdirectories to make them compile with their own CMakeLists and my main one looks like this:

cmake_minimum_required(VERSION 3.21.3)

project(Reskinner)

set(CMAKE_CXX_STANDARD 17)     
set(CMAKE_VERBOSE_MAKEFILE ON)

add_executable(${PROJECT_NAME} Main.cpp)

add_subdirectory(external/glfw)
add_subdirectory(external/assimp)
add_subdirectory(external/glad)
add_subdirectory(external/imgui)
add_subdirectory(external/stb)
add_subdirectory(external/glm)
add_subdirectory(external/FileBrowser)
add_subdirectory(src)

find_package(OpenGL REQUIRED)

target_include_directories(${PROJECT_NAME}
    PUBLIC external/glfw/include
    PUBLIC external/assimp/include
    PUBLIC external/glm
    PUBLIC external
    PUBLIC src
)

target_link_libraries(${PROJECT_NAME} glfw glad imgui stb glm Engine assimp FileBrowser)

The project was developed with visual studio on windows and I want to compile it on linux without using visualstudio. The cmake doesn't give me any errors but when i run the make command it gives me this error:

#include <assimp/quaternion.h> there's no file or directory with this name.

like i didn't put the assimp include folder in the cmake (but i did).

Do you have any idea how to make it works? I want to make a bash script to install all the dependencies and tools needed like xorg-dev, build-essential, git, cmake, make etc. So if there's any simple fix using some bash commands it's ok for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森末i 2025-02-10 01:38:34

我想出了如何修复它。我刚刚安装了柯南,并用它来下载并找到Assimp。因此,我从“外部”文件夹中删除了Assimp,GLM,GLFW和GLAD,并添加了Conanfile.txt。

在这里conanfile.txt:

[requires]
assimp/5.2.2
glfw/3.3.7
glm/0.9.9.8
glad/0.1.35

[generators]
cmake_find_package
cmake_paths

我的主要cmakelists.txt现在如下:

cmake_minimum_required(VERSION 3.21.3)

project(Reskinner)

set(CMAKE_CXX_STANDARD 17)     
set(CMAKE_VERBOSE_MAKEFILE ON)

add_executable(${PROJECT_NAME} Main.cpp)

include(${CMAKE_BINARY_DIR}/conan_paths.cmake)

#   Retrieve conan.cmake
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
    message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
    file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake")
endif ()

include("${CMAKE_BINARY_DIR}/conan.cmake")

conan_cmake_run(CONANFILE "conanfile.txt" BASIC_SETUP UPDATE BUILD missing)
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})

find_package(OpenGL REQUIRED)
find_package(glad REQUIRED)
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
find_package(assimp REQUIRED)

add_subdirectory(external/stb)
add_subdirectory(external/imgui)
add_subdirectory(external/FileBrowser)
add_subdirectory(src)

file(MAKE_DIRECTORY
        "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Shaders")

function(install_file_to_bin file_name)
    file(INSTALL "${CMAKE_SOURCE_DIR}/Shaders/${file_name}" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Shaders")
endfunction()

install_file_to_bin(1.model_loading.fs)
install_file_to_bin(1.model_loading.vs)
install_file_to_bin(4.1.fshader.fs)
install_file_to_bin(4.1.vshader.vs)
install_file_to_bin(animated_model_loading.fs)
install_file_to_bin(animated_model_loading.gs)
install_file_to_bin(animated_model_loading.vs)
install_file_to_bin(bb.vs)
install_file_to_bin(bb.fs)
install_file_to_bin(default.frag)
install_file_to_bin(default.fs)
install_file_to_bin(default.geom)
install_file_to_bin(default.vert)
install_file_to_bin(default.vs)
install_file_to_bin(floor.fs)
install_file_to_bin(floor.vs)
install_file_to_bin(framebuffer.frag)
install_file_to_bin(framebuffer.vert)
install_file_to_bin(grey_model.fs)
install_file_to_bin(grey_model.vs)
install_file_to_bin(hover.fs)
install_file_to_bin(hover.vs)
install_file_to_bin(influence_of_single_bone.fs)
install_file_to_bin(influence_of_single_bone.vs)
install_file_to_bin(mouse_shader.fs)
install_file_to_bin(mouse_shader.vs)
install_file_to_bin(normal_visualizer.fs)
install_file_to_bin(normal_visualizer.gs)
install_file_to_bin(normal_visualizer.vs)
install_file_to_bin(no_lighting_shader.fs)
install_file_to_bin(no_lighting_shader.vs)
install_file_to_bin(num_bones_visualization.fs)
install_file_to_bin(num_bones_visualization.vs)
install_file_to_bin(screen_shader.fs)
install_file_to_bin(screen_shader.vs)
install_file_to_bin(selected.fs)
install_file_to_bin(selected.vs)
install_file_to_bin(smooth_lighting_shader.fs)
install_file_to_bin(smooth_lighting_shader.vs)
install_file_to_bin(wireframe.vs)
install_file_to_bin(wireframe.fs)

set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE 1)
set(CMAKE_LINK_WHAT_YOU_USE 1)
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)

include_directories(
    ${OpenGL_INCLUDE_DIRS}
    ${glad_INCLUDE_DIRS}
    ${glfw3_INCLUDE_DIRS}
    ${glm_INCLUDE_DIRS}
    ${assimp_INCLUDE_DIRS}
    external
    src
)

target_link_libraries(${PROJECT_NAME} 
    ${OpenGL_LIBRARIES} 
    ${glad_LIBRARIES}
    ${glfw3_LIBRARIES} 
    ${glm_LIBRARIES} 
    stb
    ${assimp_LIBRARIES}
    imgui
    FileBrowser
    Engine 
)

有些笔记对其他遇到这种麻烦的人很有用:

  • assimp与柯南一起使用时有一些链接问题,因为似乎没有下载下载除了您需要的一切之外,一切都适用于#include,但它在链接阶段抱怨。添加以下3行解决了问题:

    set(cmake_cxx_include_what_you_use 1)
    set(cmake_link_what_you_use 1)
    set_property(target $ {project_name}属性internocedural_optimization true)

  • 我有一个脚本可以在linux上安装所需的所有内容,并使用conan安装东西,启动cmake等。 > 柯南安装.. [...] 我需要conan.cmake文件,以便开始寻找conan.cmake文件的线路解决了很多问题

#!/bin/bash

sudo apt-get update
sudo apt-get install git
sudo apt-get install xorg-dev
sudo apt-get install make
sudo apt-get install cmake
sudo apt-get install build-essential
cd build
rm -rf *
conan install .. --settings os="Linux" --settings compiler="gcc" --settings compiler.version=11 --build missing
cmake -S .. -B . -D CMAKE_BUILD_TYPE=Release
make
cd build

/strong> 我需要conan.cmake文件,

I figured out how to fix it. I just installed conan and used it to download and find assimp. So I removed assimp, glm, glfw and glad from 'external' folder and just added a conanfile.txt.

Here the conanfile.txt:

[requires]
assimp/5.2.2
glfw/3.3.7
glm/0.9.9.8
glad/0.1.35

[generators]
cmake_find_package
cmake_paths

my main CMakeLists.txt now it's as following:

cmake_minimum_required(VERSION 3.21.3)

project(Reskinner)

set(CMAKE_CXX_STANDARD 17)     
set(CMAKE_VERBOSE_MAKEFILE ON)

add_executable(${PROJECT_NAME} Main.cpp)

include(${CMAKE_BINARY_DIR}/conan_paths.cmake)

#   Retrieve conan.cmake
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
    message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
    file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake")
endif ()

include("${CMAKE_BINARY_DIR}/conan.cmake")

conan_cmake_run(CONANFILE "conanfile.txt" BASIC_SETUP UPDATE BUILD missing)
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})

find_package(OpenGL REQUIRED)
find_package(glad REQUIRED)
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
find_package(assimp REQUIRED)

add_subdirectory(external/stb)
add_subdirectory(external/imgui)
add_subdirectory(external/FileBrowser)
add_subdirectory(src)

file(MAKE_DIRECTORY
        "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Shaders")

function(install_file_to_bin file_name)
    file(INSTALL "${CMAKE_SOURCE_DIR}/Shaders/${file_name}" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Shaders")
endfunction()

install_file_to_bin(1.model_loading.fs)
install_file_to_bin(1.model_loading.vs)
install_file_to_bin(4.1.fshader.fs)
install_file_to_bin(4.1.vshader.vs)
install_file_to_bin(animated_model_loading.fs)
install_file_to_bin(animated_model_loading.gs)
install_file_to_bin(animated_model_loading.vs)
install_file_to_bin(bb.vs)
install_file_to_bin(bb.fs)
install_file_to_bin(default.frag)
install_file_to_bin(default.fs)
install_file_to_bin(default.geom)
install_file_to_bin(default.vert)
install_file_to_bin(default.vs)
install_file_to_bin(floor.fs)
install_file_to_bin(floor.vs)
install_file_to_bin(framebuffer.frag)
install_file_to_bin(framebuffer.vert)
install_file_to_bin(grey_model.fs)
install_file_to_bin(grey_model.vs)
install_file_to_bin(hover.fs)
install_file_to_bin(hover.vs)
install_file_to_bin(influence_of_single_bone.fs)
install_file_to_bin(influence_of_single_bone.vs)
install_file_to_bin(mouse_shader.fs)
install_file_to_bin(mouse_shader.vs)
install_file_to_bin(normal_visualizer.fs)
install_file_to_bin(normal_visualizer.gs)
install_file_to_bin(normal_visualizer.vs)
install_file_to_bin(no_lighting_shader.fs)
install_file_to_bin(no_lighting_shader.vs)
install_file_to_bin(num_bones_visualization.fs)
install_file_to_bin(num_bones_visualization.vs)
install_file_to_bin(screen_shader.fs)
install_file_to_bin(screen_shader.vs)
install_file_to_bin(selected.fs)
install_file_to_bin(selected.vs)
install_file_to_bin(smooth_lighting_shader.fs)
install_file_to_bin(smooth_lighting_shader.vs)
install_file_to_bin(wireframe.vs)
install_file_to_bin(wireframe.fs)

set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE 1)
set(CMAKE_LINK_WHAT_YOU_USE 1)
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)

include_directories(
    ${OpenGL_INCLUDE_DIRS}
    ${glad_INCLUDE_DIRS}
    ${glfw3_INCLUDE_DIRS}
    ${glm_INCLUDE_DIRS}
    ${assimp_INCLUDE_DIRS}
    external
    src
)

target_link_libraries(${PROJECT_NAME} 
    ${OpenGL_LIBRARIES} 
    ${glad_LIBRARIES}
    ${glfw3_LIBRARIES} 
    ${glm_LIBRARIES} 
    stb
    ${assimp_LIBRARIES}
    imgui
    FileBrowser
    Engine 
)

Some notes that can be usefull for other people having this troubles:

  • Assimp has some linking problem when used with conan because it seems that it doesn't download everything but just what you need so it works for the #include but it complains in the linking phase. Adding the following 3 rows fixed the problem:

    set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE 1)
    set(CMAKE_LINK_WHAT_YOU_USE 1)
    set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)

  • I have a script to install everything you need on linux and install the stuff with conan, launch the cmake etc.. Even if I install the conan packages with the command conan install .. [...] I need the conan.cmake file so the lines at the beginning looking for the conan.cmake files fixed a lot of problems

The shell scripts is the following:

#!/bin/bash

sudo apt-get update
sudo apt-get install git
sudo apt-get install xorg-dev
sudo apt-get install make
sudo apt-get install cmake
sudo apt-get install build-essential
cd build
rm -rf *
conan install .. --settings os="Linux" --settings compiler="gcc" --settings compiler.version=11 --build missing
cmake -S .. -B . -D CMAKE_BUILD_TYPE=Release
make
cd build

Hope this can help you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文