Menu

Runtime configuration of FILESDIR

Foltos
2021-08-09
2021-08-16
  • Foltos

    Foltos - 2021-08-09

    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

     
  • Daniel Marjamäki

    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
  • Paul Fultz

    Paul Fultz - 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.

     
  • Foltos

    Foltos - 2021-08-13

    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:

    <install root>
        ├── bin
           └── cppcheck
        └── share
            └── Cppcheck
                ├── addons
                   ├── <various .py files>
                ├── cfg
                   ├── <various .cfg files>
                └── platforms
                    ├── <various .xml files>
    

    By the way, this is my command line for compiling:

    cmake -S ../cppcheck-2.5/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" -DBUILD_SHARED_LIBS=OFF -DCMAKE_EXE_LINKER_FLAGS="-static" -DCMAKE_INSTALL_PREFIX=/tmp
    make install
    

    As you can see my original workaround was to run it from under /tmp.

    Thanks for helping!

    Note: I was using strace to see where cppcheck looks for files. Could have done this before asking, sorry :)

     
    • Daniel Marjamäki

      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?

       
      • Foltos

        Foltos - 2021-08-16

        It will take some time till I can get to this, but I am happy to make the change.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.