我从 https://github.com/danmar/cppcheck/tree/1.77 下载了 zip 文件, 解压缩它并给出生成 cppcheck 二进制文件的 make 命令。
接下来,当我在测试代码上运行 cppcheck 时,没有生成错误。
sles12-box:/home/test/cppchecker_test/cppcheck-1.77 # cppcheck /home/demo_code/test_code.c
Checking /home/demo_code/test_code.c ...
源码是
sles12-box:/home/test/cppchecker_test/cppcheck-1.77 # vi /home/demo_code/test_code.c
main(int argc, char* argv[])
{
char cobj[7] = "yahoo";
char *cobjPtr = cobj;
int iobj = 4;
printf("########################### CPPCHECK TEST ############################\n");
yahoo
}
当我尝试使用上述页面中指定的其他构建命令进行编译时,出现以下错误
sles12-box:/home/test/cppchecker_test/cppcheck-1.77 # make SRCDIR=build CFGDIR=cfg HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function"
make: pcre-config: Command not found
g++ -Ilib -Iexternals/simplecpp -Iexternals/tinyxml -DCFGDIR=\"cfg\" -O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function -std=c++0x -DHAVE_RULES -DTIXML_USE_STL -c -o build/analyzerinfo.o build/analyzerinfo.cpp
make: pcre-config: Command not found
g++ -Ilib -Iexternals/simplecpp -Iexternals/tinyxml -DCFGDIR=\"cfg\" -O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function -std=c++0x -DHAVE_RULES -DTIXML_USE_STL -c -o build/astutils.o build/astutils.cpp
make: pcre-config: Command not found
g++ -Ilib -Iexternals/simplecpp -Iexternals/tinyxml -DCFGDIR=\"cfg\" -O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function -std=c++0x -DHAVE_RULES -DTIXML_USE_STL -c -o build/check.o build/check.cpp
make: pcre-config: Command not found
.
.
.
我尝试构建 cppcheck 1.76 版本,但出现不同的错误:
sles12-box:/home/test/cppchecker_test/1.76/cppcheck-1.76.1 # sudo make install
Makefile:88: Extraneous text after `else' directive
Makefile:90: Extraneous text after `else' directive
Makefile:90: *** only one `else' per conditional. Stop.
如何让 cppcheck 设置准备就绪并发挥作用?
最佳答案
您是否尝试安装二进制包? https://software.opensuse.org/package/cppcheck
重新 1.77:pcre-config 是 pcre 包的一部分(很可能是开发包
关于linux - 关于 linux 设置问题的 cppcheck,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42065979/