编译protobuf-3.4.0,报错:cl is not a full path and was not found in the PATH.
当时编译protobuf时一直在报错,编译命令是:
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%cd%/install -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
尝试了很多方法失败后去stack overflow问了问,我把我的提问详细放上来吧(嫌啰嗦的可以直接看最后)
我的提问
(用的是谷歌翻译后的英文,这里我就把中文也丢上来方便看)
我想把onnx转成ncnn,在编译protobuf的时候,我先在cmake中建了一个“build”文件夹,用两个不同的文件夹分别放“release”和“debug”的配置
I want to convert onnx to ncnn, when compiling protobuf, I first built a “build” folder in cmake, and used two different folders to put the configuration of “release” and “debug” respectively:
我下载的protobuf文件目录如下:
The protobuf file directory I downloaded is as follows:
我已经下载了 cmake 和 git
I have downloaded cmake and git
编译命令:
compile command:
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../../../install ../..
当我在 windows 上安装 protobuf 时,总是会出现这个问题:
This problem always occurs when I install protobuf on windows:
它一直显示 CMakeLists.txt 的问题。
它表明没有路径,是因为没有路径吗?
It keeps showing a problem with CMakeLists.txt
And it shows that there is no path, is it because there is no path?
如果是,添加哪个路径?
If yes, which path to add?
大佬回答
The first command is just wrong and the output message explains this. In the second screenshot cmake is trying to find the Visual Studio compiler, but it it doesn’t succeed, since either there’s no visual studio installed or the compiler wasn’t added to the PATH environment variable; this is explained rather clearly in the cmake output too. The path for me btw would be C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14..\bin\Hostx**
第一个命令是错误的,输出消息解释了这一点。 在第二个屏幕截图中,cmake 试图找到 Visual Studio 编译器,但它没有成功,因为没有安装 Visual Studio,或者编译器没有添加到 PATH 环境变量中; 这在 cmake 输出中也得到了相当清楚的解释。 顺便说一句,我的路径是
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14..\bin\Hostx**
解决方法
原本我在C盘没找到编译器,准备卸载,结果卸载时跳出了我安装Visual Studio的路径,发现我把它下在了D盘,按着大佬给的路径找到我的路径后,加到了PATH里。
总而言之,就是是visual studio 编译器的路径没有放。