如何强制 CMake 使用安装在系统上的特殊版本的 Protobuf?
How to force CMake to use a special version of Protobuf installed on system?
我想将 Protobuf_INCLUDE_DIRS
设置为我选择的目录,但是,我不知道该怎么做。
$ locate FindProtobuf.cmake
/usr/share/cmake-3.16/Modules/FindProtobuf.cmake
我可以看到在 FindProtobuf.cmake
中,我们有这些:
if(Protobuf_FOUND)
set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIR})
endif()
我想在这里设置为第二个选项:
$ which -a protoc
/home/mona/anaconda3/bin/protoc
/usr/local/bin/protoc
然而,它被设置为第一个选项 /home/mona/anaconda3/bin/protoc
,尽管它在 ~/.bashrc 中被强制设置为第二个选项:/usr/local/bin/protoc
使用以下命令:alias protoc=/usr/local/bin/protoc
我的程序需要的版本是 3.6.1,alias protoc=/usr/local/bin/protoc 确保了这一点。但是,ProtobufCMake 强制路径为 /home/mona/anaconda3/bin/protoc
并且该版本为 3.13.0.
关于我面临的问题的一些信息。我正在使用 openpose 并将其安装在 Ubuntu 20.04 中,我正在使用 CMake。要求protobuf版本为3.6.1.
这里有更多内容https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/1817
消息如下:
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:469 (file):
file STRINGS file "/usr/include/google/protobuf/stubs/common.h" cannot be
read.
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:475 (math):
math cannot parse the expression: " / 1000000": syntax error, unexpected
exp_DIVIDE (2).
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:476 (math):
math cannot parse the expression: " / 1000 % 1000": syntax error,
unexpected exp_DIVIDE (2).
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:477 (math):
math cannot parse the expression: " % 1000": syntax error, unexpected
exp_MOD (2).
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Warning at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:499 (message):
Protobuf compiler version 3.13.0 doesn't match library version
ERROR.ERROR.ERROR
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
不确定上面我想做的到底是怎么做的,但是让 CMake 为 OpenPose 工作的黑客正在使用 Python venv 并评论 ~/.bashrc 中的 anaconda python 激活行:
现在,cmake-gui ..
不会抛出错误:
GCC detected, adding compile flags
GCC detected, adding compile flags
Building with CUDA.
CUDA detected: 10.1
Added CUDA NVCC flags for: sm_75
cuDNN not found
Found gflags (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libgflags.so)
Found glog (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
Caffe will be downloaded from source now. NOTE: This process might take several minutes depending
on your internet connection.
Caffe has already been downloaded.
HEAD is now at 1807aada Added Ampere arch's (CUDA11)
Caffe will be built from source now.
Download the models.
Downloading BODY_25 model...
Model already exists.
Not downloading body (COCO) model
Not downloading body (MPI) model
Downloading face model...
Model already exists.
Downloading hand model...
Model already exists.
Models Downloaded.
Configuring done
我在 ~/.bashrc 中有这个:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
##__conda_setup="$('/home/mona/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
##if [ $? -eq 0 ]; then
## eval "$__conda_setup"
##else
## if [ -f "/home/mona/anaconda3/etc/profile.d/conda.sh" ]; then
## . "/home/mona/anaconda3/etc/profile.d/conda.sh"
## else
## export PATH="/home/mona/anaconda3/bin:$PATH"
## fi
##fi
并在 Ubuntu 20.04 中安装了以下内容:
$ sudo apt-get install python3
$ sudo apt-get install python3-venv
另外,在 ~/.bashrc 中执行此操作并获取它:alias python=python3
$ python -m venv ~/venv/openpose
$ source ~/venv/openpose/bin/activate
我想将 Protobuf_INCLUDE_DIRS
设置为我选择的目录,但是,我不知道该怎么做。
$ locate FindProtobuf.cmake
/usr/share/cmake-3.16/Modules/FindProtobuf.cmake
我可以看到在 FindProtobuf.cmake
中,我们有这些:
if(Protobuf_FOUND)
set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIR})
endif()
我想在这里设置为第二个选项:
$ which -a protoc
/home/mona/anaconda3/bin/protoc
/usr/local/bin/protoc
然而,它被设置为第一个选项 /home/mona/anaconda3/bin/protoc
,尽管它在 ~/.bashrc 中被强制设置为第二个选项:/usr/local/bin/protoc
使用以下命令:alias protoc=/usr/local/bin/protoc
我的程序需要的版本是 3.6.1,alias protoc=/usr/local/bin/protoc 确保了这一点。但是,ProtobufCMake 强制路径为 /home/mona/anaconda3/bin/protoc
并且该版本为 3.13.0.
关于我面临的问题的一些信息。我正在使用 openpose 并将其安装在 Ubuntu 20.04 中,我正在使用 CMake。要求protobuf版本为3.6.1.
这里有更多内容https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/1817
消息如下:
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:469 (file):
file STRINGS file "/usr/include/google/protobuf/stubs/common.h" cannot be
read.
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:475 (math):
math cannot parse the expression: " / 1000000": syntax error, unexpected
exp_DIVIDE (2).
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:476 (math):
math cannot parse the expression: " / 1000 % 1000": syntax error,
unexpected exp_DIVIDE (2).
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:477 (math):
math cannot parse the expression: " % 1000": syntax error, unexpected
exp_MOD (2).
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Warning at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:499 (message):
Protobuf compiler version 3.13.0 doesn't match library version
ERROR.ERROR.ERROR
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
不确定上面我想做的到底是怎么做的,但是让 CMake 为 OpenPose 工作的黑客正在使用 Python venv 并评论 ~/.bashrc 中的 anaconda python 激活行:
现在,cmake-gui ..
不会抛出错误:
GCC detected, adding compile flags
GCC detected, adding compile flags
Building with CUDA.
CUDA detected: 10.1
Added CUDA NVCC flags for: sm_75
cuDNN not found
Found gflags (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libgflags.so)
Found glog (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
Caffe will be downloaded from source now. NOTE: This process might take several minutes depending
on your internet connection.
Caffe has already been downloaded.
HEAD is now at 1807aada Added Ampere arch's (CUDA11)
Caffe will be built from source now.
Download the models.
Downloading BODY_25 model...
Model already exists.
Not downloading body (COCO) model
Not downloading body (MPI) model
Downloading face model...
Model already exists.
Downloading hand model...
Model already exists.
Models Downloaded.
Configuring done
我在 ~/.bashrc 中有这个:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
##__conda_setup="$('/home/mona/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
##if [ $? -eq 0 ]; then
## eval "$__conda_setup"
##else
## if [ -f "/home/mona/anaconda3/etc/profile.d/conda.sh" ]; then
## . "/home/mona/anaconda3/etc/profile.d/conda.sh"
## else
## export PATH="/home/mona/anaconda3/bin:$PATH"
## fi
##fi
并在 Ubuntu 20.04 中安装了以下内容:
$ sudo apt-get install python3
$ sudo apt-get install python3-venv
另外,在 ~/.bashrc 中执行此操作并获取它:alias python=python3
$ python -m venv ~/venv/openpose
$ source ~/venv/openpose/bin/activate