Cmake 无法正确生成 assimp 解决方案 [Windows 10]

Posted

技术标签:

【中文标题】Cmake 无法正确生成 assimp 解决方案 [Windows 10]【英文标题】:Cmake not generating assimp solutions properly [Windows 10] 【发布时间】:2019-07-18 10:11:18 【问题描述】:

Cmake 3.15 32 位

Assimp 4.1.0

您好,我在使用 cmake 和 assimp 时遇到了一些困难。在过去的几天里,我一直在尝试通过 cmake 为 CodeBlocks 生成一个 assimp 工作区。

我尝试使用 CMD 和 CmakeGUI 方法生成解决方案,但没有令人满意的结果。

在生成项目的 GUI 标准过程中,定义了适当的源和目标路径,并选择了合适的生成器(CodeBlocks MinGW Makefiles)。

cmd中用于生成assimp项目的代码:

cmake -G "CodeBlocks - MinGW Makefiles" MakeLists.txt -S "source path" -B "build path"

生成文件后得到的信息日志:

-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Shared libraries enabled
-- Looking for DirectX...
-- DirectX_PREFIX_PATH changed.
-- Found DirectX: C:/MinGW/lib/libd3d9.a
-- DX lib dir: C:/MinGW/lib
-- Looking for ZLIB...
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could not locate ZLIB
-- compiling zlib from souces
CMake Deprecation Warning at contrib/zlib/CMakeLists.txt:8 (cmake_policy):
  The OLD behavior for policy CMP0048 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find rt (missing: RT_LIBRARY)
INFO RT-extension not found. glTF import/export will be built without Open3DGC-compression.
-- Enabled formats: AMF 3DS AC ASE ASSBIN ASSXML B3D BVH COLLADA DXF CSM HMP IRRMESH IRR LWO LWS MD2 MD3 MD5 MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD
-- Disabled formats:
-- Could NOT find IL (missing: IL_LIBRARIES IL_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:439 (MESSAGE):
  Build of assimp_qt_viewer is disabled.  Unsatisfied dendencies: Qt5 DevIL

-- Configuring done
-- Generating done
-- Build files have been written to: E:/Assimp

不幸的是,该项目无法在 CodeBlocks 中构建,并带有以下构建日志:

Checking if target is up-to-date: mingw32-make.exe -q -f Makefile all
Running command: C:/TDM-GCC-64/bin/mingw32-make.exe -f "E:/Assimp/Makefile"  VERBOSE=1 all
"C:\Program Files\CMake\bin\cmake.exe" -SC:\Users\ognje\Downloads\assimp-4.1.0 -B"E:\Assimp" --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_progress_start "E:\Assimp\CMakeFiles" "E:\Assimp\CMakeFiles\progress.marks"
C:/TDM-GCC-64/bin/mingw32-make.exe -f CMakeFiles\Makefile2 all
mingw32-make.exe[1]: Entering directory 'E:/Assimp'
C:/TDM-GCC-64/bin/mingw32-make.exe -f contrib\zlib\CMakeFiles\zlib.dir\build.make contrib/zlib/CMakeFiles/zlib.dir/depend
mingw32-make.exe[2]: Entering directory 'E:/Assimp'
[  1%] Generating zlib1rc.obj
cd /d E:\PROGRA~3\PROGRA~1\Assimp\contrib\zlib && C:\MinGW\bin\windres.exe -D GCC_WINDRES -I C:/Users/ognje/Downloads/assimp-4.1.0/contrib/zlib -I "E:/Assimp/contrib/zlib" -o "E:/Assimp/contrib/zlib/zlib1rc.obj" -i C:/Users/ognje/Downloads/assimp-4.1.0/contrib/zlib/win32/zlib1.rc
gcc: error: i\: No such file or directory
gcc: error: Assimp/contrib/zlib: No such file or directory
C:\MinGW\bin\windres.exe: preprocessing failed.
mingw32-make.exe[2]: *** [contrib/zlib/zlib1rc.obj] Error 1
mingw32-make.exe[1]: *** [contrib/zlib/CMakeFiles/zlib.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
contrib\zlib\CMakeFiles\zlib.dir\build.make:60: recipe for target 'contrib/zlib/zlib1rc.obj' failed
mingw32-make.exe[2]: Leaving directory 'E:/Assimp'
CMakeFiles\Makefile2:134: recipe for target 'contrib/zlib/CMakeFiles/zlib.dir/all' failed
mingw32-make.exe[1]: Leaving directory 'E:/Assimp'
E:/Assimp/Makefile:128: recipe for target 'all' failed
Process terminated with status 2 (0 minute(s), 0 second(s))
6 error(s), 0 warning(s) (0 minute(s), 0 second(s))

免责声明:

当然,我已经用谷歌搜索并尝试了网络上所有现有的解决方案[1] 来解决这个特殊问题,但令人失望的是,它们都不起作用。老实说,我对编译和库了解不多,但我认为在阅读错误日志时,我会说问题源于 zlib 文件,对吧?谁能帮我解决这个问题?提前谢谢你。

【问题讨论】:

E:/Assimp/contrib/zlib 存在吗?生成的构建命令似乎依赖它。如果可行,请考虑在他们的项目页面上提出问题,因为树外构建(您正在尝试执行的操作)似乎已损坏。 是的,事实上E:/Assimp/contrib/zlib确实存在。 【参考方案1】:

问题是由错误的检测环境引起的。 zlib-script 尝试对 windows-resource-build 使用以下选项:

C:\MinGW\bin\windres.exe -D GCC_WINDRES -I C:/Users/ognje/Downloads/assimp-4.1.0/contrib/zlib -I "E:/Assimp/contrib/zlib" -o "E:/Assimp/contrib/zlib/zlib1rc.obj" -i C:/Users/ognje/Downloads/assimp-4.1.0/contrib/zlib/win32/zlib1.rc

选项 -i 将被识别为文件令牌:

gcc: error: i\: No such file or directory

因此,zlib 的构建失败,因为用作参数的选项混淆了以下内容的 gcc 解析,在本例中为目标 zlib:

gcc: error: Assimp/contrib/zlib: No such file or directory

我猜这是由于在使用特殊版本的 mingw 时缺少必须构建的代码标识造成的。您能否打开一份问题报告,其中包含您正在使用的 veYOu can do rsion of assimp 以及您的构建中使用了哪个 gcc 版本。您可以在这里执行此操作:Issue-tracker of Asset-Importer-Lib Project

【讨论】:

对不起,这个问题在发布后一天就解决了。我可以发誓我已经回复了这个帖子,声称我修复了它。所以首先,我必须承认一些事情,在创建这个线程之前,我故意缩短并将原始 Assimp 源位置“E:\Programiranje i Matematika\Programiranje\Graficko\OpenGL\Assimp”翻译为“E:\Assimp”,认为它对读者来说会更容易。 Cmake 似乎失败了,路径在其层次结构中有空格。所以我只是在 Cmake 中将目标构建从上述更改为 E:\Assimp,现在当我尝试从解决方案构建库时,完成 60% 后出现以下错误:..\mingw\lib\libmingwex.a(vsnprintf.o)|| multiple definition of 'vsnprintf'; CMakeFiles\assimp.dir/objects.a(AssxmlExporter.cpp.obj):AssxmlExporter.cpp:(.text$vsnprintf[_vsnprintf]+0x0): first defined here| 问题仍然存在。 assimp 的哪个版本?

以上是关于Cmake 无法正确生成 assimp 解决方案 [Windows 10]的主要内容,如果未能解决你的问题,请参考以下文章

Windows 上 Assimp(Open Asset Import Library) 源码的编译 及 Samples 的编译运行

使用find_package链接assimp库

带有骨骼的 Assimp + COLLADA 模型 = 不正确的顶点位置

从 Assimp 加载 Collada (dae) 模型显示不正确的法线

CMAKE利用MinGW32编译

Mac OS下安装assimp