cppcheck std.cfg not found error when std.cfg file is available
Asked Answered
S

6

22

If i launch my cppcheck i get following error: cppcheck ListLib.c (information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to "/usr/bin/cfg" and will therefore search for std.cfg in that path.

System : opensuse13 ,cppcheck version: cppcheck-1.64 , compiled with : make SRCDIR=build CFGDIR=/usr/bin/cfg HAVE_RULES=yes

checking if file is there: ls /usr/bin/cfg : gtk.cfg posix.cfg qt.cfg sdl.cfg std.cfg windows.cfg

whereis cfg: cfg: /usr/bin/cfg

whereis std.cfg: std: /usr/bin/cfg/std.cfg

cat std: /usr/bin/cfg/std.cfg gives me the output from that file

Stacktrace:

lstat("/home/.../ListLib.c", {st_mode=S_IFREG|0644, st_size=4568, ...}) = 0
stat("/home/.../ListLib.c", {st_mode=S_IFREG|0644, st_size=4568, ...}) = 0
open("std.cfg", O_RDONLY)               = -1 ENOENT (No such file or directory)
open("cfg/std.cfg", O_RDONLY)           = -1 ENOENT (No such file or directory)
write(2, "(information) Failed to load std"..., 213) = 213
write(2, "\n", 1)                       = 1
exit_group(1)                           = ?
+++ exited with 1 +++

changing to /usr/bin directory works: Checking /.../ListLib.c

cppcheck --check-config ListLib.c: gives the same error and works just fine if i do it in /usr/bin/

Okey for people landing on this page i got it working with the cfg files in my homefolder:

make SRCDIR=build CFGDIR=~/cppcheck_cfg and then offcourse
sudo make install

Steenbok answered 18/3, 2014 at 17:22 Comment(5)
The cppcheck --check-config option may have some useful output.Thesis
cppcheck --check-config ListLib.c: gives the same error and works just fine if i do it in /usr/bin/Steenbok
This worked for me: cd /home/kubuntu/Projects/cppcheck && make SRCDIR=build CFGDIR=/home/kubuntu/Projects/cppcheck/cfg/std.cfg -j3 && sudo make install -j3 It seems like CFGDIR must actually be a file NOT a directory!Keek
CFGDIR has to be a Dir note how it states CFDIR and not CFG file , from the muanual: The .cfg files are needed by cppcheck. Either put them in a subfolder cfg where the binary is. Otherwise compile cppcheck with CFGDIR to specify an arbitrary path where you put the .cfg files. I even have multiple cgf files dont see this working properly, seems bad practiceSteenbok
The cppcheck README gives the preferred make line: github.com/danmar/cppcheckOftentimes
B
26

I faced the same problem too.

Solution:

$ make SRCDIR=build CFGDIR=/usr/share/cppcheck/

$ sudo make install CFGDIR=/usr/share/cppcheck/

Got suggestions from the cppcheck community members and came to know that 'make install' also requires the CFGDIR option to be passed.

Baer answered 30/10, 2014 at 10:7 Comment(1)
I dug into the Makefile and found out the reason: make install also builds the code inside the lib directory, which does not get compiled by simply calling make.Rushy
T
4
make SRCDIR=build CFGDIR=/usr/bin/cfg HAVE_RULES=yes

make install CFGDIR=/usr/bin/cfg
Trophozoite answered 29/8, 2014 at 13:43 Comment(2)
I think it would benefit the question and future users if you were to explain what this does step by step.Cachinnate
Only thing different here is the HAVE_RULES=yes, i just saw that the manual now recomments have_rules=yes. Just "make install" is also fine here no point in repeating CFGDIR=/usr/bin/cfg.Steenbok
S
2

I had same issue few days ago and solved by changing the way I run makefile on cppcheck.

I use Linux Red Hat version and cppcheck version is 1.65.

make SRCDIR=build CFGDIR=/home/###/####/cppcheck-1.65/cfg/ && make install

I didn't really dig into the detail but makefile of cppcheck look like they are clearing up obj and build cppcheck including cfg location by first make command

make SRCDIR=build CFGDIR=/home/###/####/cppcheck-1.65/cfg/ &&

and second make command would distribute cppcheck into /usr/bin/ location.

make install

Now all you have to do is to set up bash.

Singlet answered 8/7, 2014 at 4:30 Comment(1)
See answer of @prabhugs: The make install command also requires CFGDIR to be set.Rushy
T
1

Check permissions, with file /usr/bin/cfg/std.cfg, to ensure you have permissions to access the config file that you think it should be trying to read.

Then, failing that, run cppcheck under strace to find the system call that's failing: strace -o /tmp/strace.out cppcheck ListLib.c.

Thesis answered 18/3, 2014 at 17:40 Comment(4)
permissions are 777, i tried the stacktrace and got following error: open("std.cfg", O_RDONLY) = -1 ENOENT (No such file or directory) open("cfg/std.cfg", O_RDONLY) = -1 ENOENT (No such file or directory) write(2, "(information) Failed to load std"..., 213) = 213 write(2, "\n", 1) = 1 exit_group(1) = ? if i do whereis std.cfg i get std: /usr/bin/cfg/std.cfgSteenbok
The strace output suggests it's only checking the current directory and a "cfg" subdirectory for the ".cfg" files. Try cding to /usr/bin before running cppcheck to see if that satisfies it. (My version of cppcheck (1.60.1) does not have the CFGDIR build-time configuration option)Thesis
This suggest to me that the CFGDIR setting is not working as expected. Perhaps try rebuilding cppcheck in a clean directory, to ensure the CFGDIR setting is as you expect. Then run the cppcheck built there.Thesis
Thank you for your help, posted the solution for othersSteenbok
M
0

I ran into the same problem running cppCheck GUI on a directory after compiling it on a Mac with Qt Creator and running the GUI version. I solved the problem by copying "std.cfg" into the application folder: Contents/MacOS You have to right-click the cppcheck-gui application to access the contents. Its seems to be ok to put it beside the cppcheck-gui file in the same folder as that must be where it checks first. The "std.cfg" file can be found in the cfg folder.

Mosera answered 25/4, 2017 at 22:43 Comment(0)
K
0

As @prabhugs said, I will make more description. In the source code of the github,cppcheck, It's recommended that the make syntax is:

$ make SRCDIR=build CFGDIR=cfg HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function

where the "CFGDIR" option is a dirction that you can spicify. For example:

$ make SRCDIR=build CFGDIR=/usr/share/cppcheck HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function

And then, you can use this sytax:

$ sudo make install CFGDIR=/usr/share/cppcheck/

after these step ibelieve you can enjoy the cppcheck.

Kibitzer answered 19/6, 2019 at 6:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.