简体   繁体   English

构建开放资产导入库 (Assimp) 时遇到问题

[英]Trouble building the Open Asset Import Library (Assimp)

I have just downloaded the Open Asset Import Library (Assimp) which is an API used to import 3D file formats such as .3DS and .Obj into source code.我刚刚下载了 Open Asset Import Library (Assimp),它是一个 API,用于将 .3DS 和 .Obj 等 3D 文件格式导入源代码。 Doing so allows for much easier rendering of meshes using openGL.这样做可以更轻松地使用 openGL 渲染网格。

The problem is, I can't get the Library to build.问题是,我无法建立图书馆。 It comes with very vague and cryptic directions on how to build it and connect to a compiler such as XCode (which I am using).它附带了关于如何构建它并连接到诸如 XCode(我正在使用的编译器)之类的编译器的非常模糊和神秘的说明。 It says I should use a program called CMake to build the library.它说我应该使用一个名为 CMake 的程序来构建库。 I have downloaded CMake and tried to use it but it has not yet worked for me.我已经下载了 CMake 并尝试使用它,但它尚未对我有用。

Has anyone here successfully built and installed Assimp using CMake or some other tool?这里有没有人使用 CMake 或其他工具成功构建和安装 Assimp?

I totally agree that the documentation for Mac is a bit lacking, but I have managed (after several attempts) to build and install the library.我完全同意 Mac 的文档有点缺乏,但我已经设法(经过多次尝试)构建和安装库。

A few things before starting: make sure you have installed XCode Command Line Tools (that installs the GNU compiler).开始之前的一些事情:确保您已经安装了 XCode 命令行工具(安装了 GNU 编译器)。 These are the steps I followed:这些是我遵循的步骤:

  1. Download the latest release of Assimp and extract it (I got the file from here, the one with source only: http://sourceforge.net/projects/assimp/files/assimp-3.0/ )下载最新版本的 Assimp 并解压(我从这里得到文件,只有源文件: http : //sourceforge.net/projects/assimp/files/assimp-3.0/
  2. If you don't have it, install CMake ( http://www.cmake.org/cmake/resources/software.html ; I'm currently using an older version, but the latest one should work fine as well)如果没有,请安装 CMake( http://www.cmake.org/cmake/resources/software.html ;我目前使用的是旧版本,但最新版本也应该可以正常工作)
  3. Create a build directory (should be outside the source directory)创建构建目录(应该在源目录之外)
  4. Open CMake and point it to the folder you created at step 1 (where it says "Where is the source code");打开 CMake 并将其指向您在步骤 1 中创建的文件夹(其中显示“源代码在哪里”); the other folder ("Where to build the binaries") should point to the folder created at step 3另一个文件夹(“在哪里构建二进制文件”)应该指向在步骤 3 中创建的文件夹
  5. Click "Configure" on the bottom;点击底部的“配置”; it will ask you which environment you'd like to use.它会询问您想使用哪种环境。 I picked "Eclipse CDT 4 - Unix Makefiles"我选择了“Eclipse CDT 4 - Unix Makefiles”
  6. You should get a list of options;你应该得到一个选项列表; the two I selected were "BUILD_STATIC_LIB" and "ENABLE_BOOST_WORKAROUND"我选择的两个是“BUILD_STATIC_LIB”和“ENABLE_BOOST_WORKAROUND”
  7. Click "Generate"点击“生成”
  8. Now you should move to the terminal and go to the folder created at step 3现在您应该移动到终端并转到在步骤 3 中创建的文件夹
  9. Type "make" and launch it;输入“make”并启动它; you should see the build progressing without issues你应该看到构建进展没有问题
  10. When the build is finished, type "sudo make install";构建完成后,输入“sudo make install”; it will ask for your password and install the library它会询问您的密码并安装库

After the last step you should be able to include the library in your code:在最后一步之后,您应该能够在代码中包含该库:

#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

Make sure you also include the library for linking;确保您还包含用于链接的库; when linking you should add -lassimp to the list链接时,您应该将 -lassimp 添加到列表中

Let me know if you have any issues with the steps above!如果您对上述步骤有任何问题,请告诉我!

I had a slightly different approach that worked for me building assimp on Mac.我有一种稍微不同的方法,它适用于我在 Mac 上构建 assimp。 Here are the steps that I took if it helps anybody.如果对任何人有帮助,以下是我采取的步骤。

Step 1 - Install Libraries with Homebrew第 1 步 - 使用 Homebrew 安装库

brew install glm glew assimp

Step 2 - Update my CMake with the Following第 2 步 - 使用以下内容更新我的 CMake

FIND_PACKAGE(ASSIMP REQUIRED)
LINK_DIRECTORIES(/usr/local/lib)

add_executable(
    myExecutable
    ...
)

TARGET_LINK_LIBRARIES( myExecutable PRIVATE ${ASSIMP_LIBRARIES} )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM