我正在从these sources编译一个Google protobuf插件。
我用homebrew命令安装了[email protected]:
brew安装[email protected]
安装后,通过调用make
尝试编译时出现以下错误:
Richards-Mac-mini:protobuf-objc-arc richard$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in src/compiler
g++ -DHAVE_CONFIG_H -I. -I../.. -g -O2 -DNDEBUG -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cc
main.cc:17:10: fatal error: 'google/protobuf/compiler/plugin.h' file not found
#include <google/protobuf/compiler/plugin.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [main.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
特别是,这条线很有意思:
致命错误:找不到'google / protobuf / compiler / plugin.h'文件
虽然我绝对能够走这条路并找到plugin.h
文件:
/US人/local/cellar/proto部分@2.5/2.5.0/include/Google/proto部分/compiler/plugin.还
看起来,像库没有正确链接二进制文件,问题以某种方式与正确的路径相关。
当我尝试发出命令which protoc
时,我得到:
/US人/local/opt/proto部分@2.5/斌/proto C
protoc --version
导致以下输出,这是预期的。
libprotoc 2.5.0
通过发出以下命令修复:
brew链接--force --overwrite protobuf250
输出:
Linking /usr/local/Cellar/[email protected]/2.5.0... 14 symlinks created
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
然后:
echo'export PATH =“/ usr / local / opt /protobuf @ 2.5 / bin:$ PATH”'>>〜/ .bash_profile
成功链接后,我能够无错误地编译Objective-C插件。