opengl 可创建mingw-w 64 VSCode win10

8yoxcaq7  于 2022-11-04  发布在  Vscode
关注(0)|答案(1)|浏览(192)

更新

通过禁用X1 MON 1X,可以由MingW-W 64(GCC版本12.2.0)成功地构建ASIGMP(5.2.5)的较新版本。
但是,它无法加载以前由msvc构建的assimp加载的.obj模型(该模型在opengl场景中不显示)。
Assimp 5.2.5 compiled by cmake-gui and mingw-w64 faild to load .obj model in opengl rendering

UPDATE:assimp的开发人员已经确认了该错误,并计划在5月26日将其添加到Planning for Release V5.1中的ToDo来修复该错误。

https://github.com/assimp/assimp/issues/3221
我尝试在opengl中使用assimp,下面是构建说明:https://github.com/assimp/assimp/blob/master/Build.md,在以下环境中:

assimp 5.0.1    
cmake 3.17.2
mingw-w64 with gcc/g++ 8.1.0
VSCode in Win10

我试过在cmake-gui中,使用MinGW的Makefile,我可以在构建路径中获得一个makefile。
然后,我尝试通过mingw 32-make来实现它,并在69%处停止,

[ 67%] Linking CXX shared library libassimp.dll
[ 67%] Built target assimp
Scanning dependencies of target assimp_cmd
[ 67%] Building RC object tools/assimp_cmd/CMakeFiles/assimp_cmd.dir/assimp_cmd.rc.obj
[ 68%] Building CXX object tools/assimp_cmd/CMakeFiles/assimp_cmd.dir/CompareDump.cpp.obj
[ 68%] Building CXX object tools/assimp_cmd/CMakeFiles/assimp_cmd.dir/ImageExtractor.cpp.obj
[ 68%] Building CXX object tools/assimp_cmd/CMakeFiles/assimp_cmd.dir/Main.cpp.obj
[ 68%] Building CXX object tools/assimp_cmd/CMakeFiles/assimp_cmd.dir/WriteDumb.cpp.obj
[ 69%] Building CXX object tools/assimp_cmd/CMakeFiles/assimp_cmd.dir/Info.cpp.obj
[ 69%] Building CXX object tools/assimp_cmd/CMakeFiles/assimp_cmd.dir/Export.cpp.obj
[ 69%] Linking CXX executable assimp.exe
CMakeFiles\assimp_cmd.dir/objects.a(Main.cpp.obj):Main.cpp:(.text+0x8d): undefined reference to `Assimp::Importer::ValidateFlags(unsigned int) const'
CMakeFiles\assimp_cmd.dir/objects.a(Main.cpp.obj):Main.cpp:(.text+0xc4): undefined reference to `Assimp::Importer::ReadFile(char const*, unsigned int)'
CMakeFiles\assimp_cmd.dir/objects.a(Main.cpp.obj):Main.cpp:(.text+0x14e): undefined reference to `Assimp::DefaultLogger::create(char const*, Assimp::Logger::LogSeverity, unsigned int, Assimp::IOSystem*)'
CMakeFiles\assimp_cmd.dir/objects.a(Main.cpp.obj):Main.cpp:(.text+0x183): undefined reference to `Assimp::DefaultLogger::kill()'
CMakeFiles\assimp_cmd.dir/objects.a(Main.cpp.obj):Main.cpp:(.text+0x1b8): undefined reference to `Assimp::Importer::GetErrorString() const'
......
......
......
CMakeFiles\assimp_cmd.dir/objects.a(Export.cpp.obj):Export.cpp:(.text+0xf44): undefined reference to `Assimp::Exporter::GetExportFormatDescription(unsigned long long) const'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]:***[tools\assimp_cmd\CMakeFiles\assimp_cmd.dir\build.make:197: tools/assimp_cmd/assimp.exe] Error 1
mingw32-make[1]:***[CMakeFiles\Makefile2:297: tools/assimp_cmd/CMakeFiles/assimp_cmd.dir/all] Error 2
mingw32-make:***[Makefile:149: all] Error 2

虽然我可以在构建目录中得到一个“libassimp.dll”和一个“libassimp.dll.a”,但我无法将它们链接到我的项目中。有许多“未定义对xxxx的引用”错误。
1.我将.dll文件放在exe路径中,将.a文件放在lib路径中,将所有的assimp .h文件放在include路径中。

  1. VSCode似乎不支持文件名“libassimp.dll.a”,我不得不将其重命名为libassimpdll.a并在tasks.json中写入“-lassimp”。但存在“未定义引用”错误。
    1.我试着构建VS 2017的assimp,我可以得到dll和lib。
    1.我试图直接链接assimp 3.1.1(带有已经正式提供的x86/x64 dll和lib),但也失败了。
    因此,我的问题是是否有人成功地使用cmake和mingw-w 64构建了assimp,并将其链接到VSCode Win10中的项目中?
mec1mxoz

mec1mxoz1#

我可以使用以下代码构建assimp 5.0.1:

cmake.exe -G"MSYS Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=/usr/local -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS:BOOL=OFF -DASSIMP_BUILD_ASSIMP_TOOLS:BOOL=OFF -DASSIMP_HEADERCHECK:BOOL=OFF -DASSIMP_OPT_BUILD_PACKAGES:BOOL=OFF -DSYSTEM_IRRXML:BOOL=OFF -DASSIMP_BUILD_SAMPLES:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DASSIMP_BUILD_TESTS:BOOL=OFF -S. -Bbuild_win &&
make -Cbuild_win &&
echo Success

甚至在MSYS2外壳下的-DBUILD_SHARED_LIBS:BOOL=ON也是如此。
但它不适用于-DASSIMP_BUILD_ASSIMP_TOOLS:BOOL=ON

相关问题