MNN windows环境编译 c++.exe: error: /wd4267: No such file or directory

按照https://www.yuque.com/mnn/cn/build_windows编译windows下的MNN

cd /path/to/MNN
powershell ./schema/generate.ps1
mkdir build
cd build
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ..
ninja

在windows10上出现

C:\MinGW\bin\c++.exe  -DBUILDING_MNN_DLL -DMNN_SUPPORT_TFLITE_QUAN -DMNN_USE_SSE -DMNN_USE_THREAD_POOL -DMNN_VERSION=\"0.2.1.5git\" -DMNN_VERSION_MAJOR=0 -DMNN_VERSION_MINOR=2 -DMNN_VERSION_PATCH=1 -D_CRT_SECURE_NO_WARNINGS -I../include -I../source -I../schema/current -I../3rd_party -I../3rd_party/flatbuffers/include -I../3rd_party/half -I../3rd_party/imageHelper -I../3rd_party/OpenCLHeaders /wd4267 /wd4018 /wd4251 /wd4996 /wd4244 /wd4146 /wd4129 /wd4305 /wd4275 -std=c++11 -O3 -O3 -DNDEBUG /Zi   -std=gnu++11 -MD -MT CMakeFiles/MNNCore.dir/source/core/BackendRegister.cpp.obj -MF CMakeFiles\MNNCore.dir\source\core\BackendRegister.cpp.obj.d -o CMakeFiles/MNNCore.dir/source/core/BackendRegister.cpp.obj -c ../source/core/BackendRegister.cpp
c++.exe: error: /wd4267: No such file or directory
c++.exe: error: /wd4018: No such file or directory
c++.exe: error: /wd4251: No such file or directory
c++.exe: error: /wd4996: No such file or directory
c++.exe: error: /wd4244: No such file or directory
c++.exe: error: /wd4146: No such file or directory
c++.exe: error: /wd4129: No such file or directory
c++.exe: error: /wd4305: No such file or directory
c++.exe: error: /wd4275: No such file or directory
c++.exe: error: /Zi: No such file or directory
[14/266] Generating Version Control Info
-- Found Git: D:/git/Git/cmd/git.exe (found version "2.17.1.windows.2")
ninja: build stopped: subcommand failed.

https://github.com/alibaba/MNN/issues/266
https://github.com/alibaba/MNN/issues/560
在以上github issue中也是同样的问题,但一方面作者说在master里改了下,但经测试多个版本(包括直接windows下载多个版本以及git clone or git clone --recursive)依然报以上错误;同时按照issue中的方法修改CMakeLists.txt没用,当然自己对cmake语法也不太熟悉;

解决方法:
首先把前几个步骤做完

cd /path/to/MNN
powershell ./schema/generate.ps1
mkdir build
cd build

再按照
https://zhuanlan.zhihu.com/p/62416504
https://blog.csdn.net/ezhchai/article/details/80557936
上步骤使用cmake-gui先configure configure generate,再在生成的build文件夹找到sln文件进行vs下的编译,注意了在vs的编译使用的解决方案配置为debug,解决方案平台应该和cmake-gui中configure时相同,比如下图configure时选择的是x64,vs的解决方案平台应该使用x64
MNN windows环境编译 c++.exe: error: /wd4267: No such file or directory_第1张图片

其他小问题:
问题:
执行

powershell ./schema/generate.ps1

出现如下错误

flatc.exe' is not recognized as t he name of a cmdlet

解决
重新git clone --recursive,应该是MNN的版本过旧导致的

ninja安装:
https://blog.csdn.net/qq_20373723/article/details/84061647

执行

git checkout release

出现如下错误

error: Your local changes to the following files would be overwritten by checkout:
git add.
git commit -m "commit message"

解决
注意这里add后加空格再加.
https://blog.csdn.net/qq_32452623/article/details/75645578

你可能感兴趣的:(MNN)