in my environment I have to run the newest cppcheck on an old Linux machine
where I do not have sudo rights. As a result I have to compile cppcheck on
one machine into a static executable and I am trying to run it from
arbitrary location (i.e. <some random="" changing="" path="">/cppchk) on another one
machine.
Unfortunately cppcheck tries to open .cfg files from FILESDIR and the
location seems to be compiled into the executable. In my environment the
location of the configuration files can not be foretold, and thus cppcheck
fails to find it's configuration files.
Is there any workaround for this? Is it possible to specify FILESDIR
run-time?</some>
It is not possible to specify FILESDIR at runtime unfortunately. But how do you compile Cppcheck? If the FILESDIR is not defined then cppcheck should check for files locally. You can have a folder /opt/cppcheck or maybe ~/cppcheck that contains all the files both the binary and the data files.
Last edit: Daniel Marjamäki 2021-08-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Cppcheck will still search relative paths even if FILESDIR is defined. So if you put the cfg and addons directory in the same directory as cppcheck executable then cppcheck will find it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am compiling with cmake (see commands at the end) . I was trying to keep the original relative paths make install creates, but that was not working.
Based on your comment above I tried various different paths for the executable and moving it to share/Cppcheck did the trick indeed, so problem is solved.
Wondering if it would be worth to extend the search paths to look for the cfg files with ../share/Cppcheck. This would make cppcheck find it's files if the installation directory is moved as-is.
This is the installation tree I get:
Wondering if it would be worth to extend the search paths to look for the cfg files with ../share/Cppcheck. This would make cppcheck find it's files if the installation directory is moved as-is.
Yes I think that sounds worth.. I wonder if you volounteer to make a github pull request?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
in my environment I have to run the newest cppcheck on an old Linux machine
where I do not have sudo rights. As a result I have to compile cppcheck on
one machine into a static executable and I am trying to run it from
arbitrary location (i.e. <some random="" changing="" path="">/cppchk) on another one
machine.
Unfortunately cppcheck tries to open .cfg files from FILESDIR and the
location seems to be compiled into the executable. In my environment the
location of the configuration files can not be foretold, and thus cppcheck
fails to find it's configuration files.
Is there any workaround for this? Is it possible to specify FILESDIR
run-time?</some>
/Foltos
It is not possible to specify FILESDIR at runtime unfortunately. But how do you compile Cppcheck? If the FILESDIR is not defined then cppcheck should check for files locally. You can have a folder /opt/cppcheck or maybe ~/cppcheck that contains all the files both the binary and the data files.
Last edit: Daniel Marjamäki 2021-08-12
Cppcheck will still search relative paths even if
FILESDIR
is defined. So if you put the cfg and addons directory in the same directory as cppcheck executable then cppcheck will find it.I am compiling with cmake (see commands at the end) . I was trying to keep the original relative paths
make install
creates, but that was not working.Based on your comment above I tried various different paths for the executable and moving it to
share/Cppcheck
did the trick indeed, so problem is solved.Wondering if it would be worth to extend the search paths to look for the cfg files with
../share/Cppcheck
. This would make cppcheck find it's files if the installation directory is moved as-is.This is the installation tree I get:
By the way, this is my command line for compiling:
As you can see my original workaround was to run it from under /tmp.
Thanks for helping!
Note: I was using
strace
to see wherecppcheck
looks for files. Could have done this before asking, sorry :)Yes I think that sounds worth.. I wonder if you volounteer to make a github pull request?
It will take some time till I can get to this, but I am happy to make the change.