cppcheck std.cfg not found error when std.cfg file is available - cppcheck

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

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.

make SRCDIR=build CFGDIR=/usr/bin/cfg HAVE_RULES=yes
make install CFGDIR=/usr/bin/cfg

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.

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.

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.

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.

Related

g++ in WSL has created an undeleteable file

I compiled a basic C++ file 'simple.cpp' into an executable 'simple' using g++ under WSL (g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0). After creating this executable, I am unable to delete it.
I've tried deleting with rm -rf simple, sudo rm -rf simple, deleting via Windows Explorer (the security tab is missing in properties) and del simple in an elevated Command Prompt. Interestingly, sudo rm -rf simple returns 0, indicating sucess, but ls -l shows the file is still there, but unreadable. even to sudo ls -l it displays the following:
ls: cannot access 'simple': No such file or directory
total 128
-????????? ? ? ? ? ? simple
-rwxrwxrwx 1 seb seb 28 Aug 6 17:25 simple.cpp
Attempting to chmod or chown the file fails with cannot access 'simple': No such file or directory as well.
The simple.cpp file contains the very innocuous:
int main() {
return 0;
}
I expected that one of the 4 methods described would get rid of the file, but everything fails.
This is usually due to a process having a handle to the file.
You could try to kill said process but I would recommend just restarting your computer and trying to delete the file

sclite (SCTK) install, file not recognized, file format not recognized, Cygwin

I am currently trying to install NIST's sclite, which is part of SCTK 2.4.0 (github or current version). I am attempting the install on Cygwin in bash. The installation is done using make.
What I've Done
I made a directory for the install and navigated to that directory
mkdir sctk2.4.0
cd sctk2.4.0
( You'll possibly need $ cd /path/to/dir/sctk2.4.0 .)
I cloned the project from github
git clone https://github.com/chinshr/sctk.git
navigated into the base folder
cd sctk
then I started following the instructions in the INSTALL file.
Running
make config
worked fine, but after typing
make all
I got the output that follows
(mkdir -p bin)
(cd src; make all)
make[1]: Entering directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src'
(cd asclite; make all)
make[2]: Entering directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/asclite'
(cd core; make all)
make[3]: Entering directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/asclite/core'
g++ -o asclite -g -Os alignment.o segment.o sgml_reportgenerator.o alignedsegmentiterator.o reportgenerator.o speechset.o segmentsgroup.o logger.o tokenalignment.o sgml_generic_reportgenerator.o recording.o statistics.o compressedlevenshteinmatrix.o segmentor.o id.o trntrn_segmentor.o linestyle_inputparser.o inputparser.o levenshteinmatrix.o levenshtein.o uemfilter.o speakermatch.o spkrautooverlap.o graphalignedsegment.o rawsys_reportgenerator.o graphalignedtoken.o timedobject.o stt_scorer.o aligner.o arraylevenshteinmatrix.o graph.o main.o trn_inputparser.o alignedspeech.o token.o alignedsegment.o graph_coordinate.o rttm_inputparser.o scorer.o properties.o ctmstmrttm_segmentor.o filter.o speech.o alignedspeechiterator.o stm_inputparser.o checker.o ctm_inputparser.o lzma/LzFind.o lzma/LzmaEnc.o lzma/Alloc.o lzma/LzmaLib.o lzma/LzmaDec.o -lm
alignment.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make[3]: *** [makefile:62: asclite] Error 1
make[3]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/asclite/core'
make[2]: *** [makefile:12: all] Error 2
make[2]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/asclite'
make[2]: *** [makefile:12: all] Error 2
make[2]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src'
make: *** [makefile:20: all] Error 2
I've looked at this SO post, but I've determined that the alignment.o file is not corrupted. Just in case, I tried a few make clean and even re-cloned the project from github, but I still get the same error.
Can anyone help me complete this installation, or at least get to the next step?
System Details
$ uname -a
CYGWIN_NT-6.1 MyMachine 2.10.0(0.325/5/3) 2018-02-02 15:16 x86_64 Cygwin
$ bash --version
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin) ...
$ gcc --version
gcc (GCC) 6.4.0 ...
$ g++ --version
g++ (GCC) 6.4.0 ...
$ make --version
GNU Make 4.2.1
Built for x86_64-unknown-cygwin ...
$ systeminfo | sed -n 's/^OS\ *//p'
Name: Microsoft Windows 7 Enterprise
Version: 6.1.7601 Service Pack 1 Build 7601
Manufacturer: Microsoft Corporation
Configuration: Member Workstation
Build Type: Multiprocessor Free
Note
I'm asking about this problem and then giving an answer to my own question. (I like that StackOverflow is allowing us to do that.) Hopefully, this will make it easier for people to help me with the problems I ran into further in the installation.
The next problem I ran into is discussed here. You can see this next problem in the answer to this problem.
This is the 'EASIER' solution.
Here are the details on what I called "the kaldi solution". Right now, it's just a list of commands without details. As shown here, these commands will install a sclite-2.4.10 directory under the $HOME (~) directory:
$ cd
$ git clone https://github.com/kaldi-asr/kaldi.git
$ cd kaldi/tools
$ extras/check_dependencies.sh
$ make -j $(nproc --all)
$ cp -R sctk-2.4.10 ~/
$ cd
$ rm -rf kaldi
$ cd sctk-2.4.10/
$ cp $HOME/.bashrc "${HOME}/.bashrc.$(date +%Y%m%d-%H%M%S).bak"
$ echo -e "\n\n## Allow access to sclite, rfilter, etc" >> $HOME/.bashrc
$ echo 'export PATH='"$(pwd)/bin"':$PATH' >> $HOME/.bashrc
$ source ~/.bashrc
See this question/answer for details on how to use it on Windows.
(See my comment under the question for the kaldi solution.)
The solution to this problem was in the README, as solutions often are. Note: There was another problem which came up after this problem was solved. See the bottom of this answer for help with that.
Here is the command I used to get the pertinent info from the README.
cat README | tail -13
and here is the pertinent info
64 bits Compilation
With big alignments, sctk needs to be compiled in 64 bits.
By default, the C/C++ software are compiled in 32 bits with the options (-Os)
but can be compiled in 64 bits, -m64 is added to the CFLAGS variable in:
src/asclite/core/makefile
src/asclite/test/makefile
src/rfilter1/makefile
src/sclite/makefile
Example of CFLAGS:
For OSX 10.4+: -fast -m64 -arch x86_64 -arch ppc64
So, I went to the makefiles listed (except rfilter1, see below) and changed the code there, replacing each -Os with -m64. Do this ONLY for the makefiles that are listed. I'll give an example for one of the listed files, but note you will have to do it for the others.
cd sctk
vim src/asclite/core/makefile
When the file was open, I found the line:
CFLAGS = -g -Os
which I changed to
CFLAGS = -g -m64
(pressed "i" to get into INSERT mode, made the change, pressed "Esc", then pressed ":wq" (Write and Quit) followed by "Enter")
I made the changes in all the listed files EXCEPT src/rfilter1/makefile, because that file had no -Os in it. This ended up being important, as the install wouldn't work if I had changed this file at all.
After this was completed, I ran make clean, but I DID NOT run make config, because this would have undone the changes we just make. I went directly to:
make all
This gets us past where we were before.
This problem was taken care of, but there was another problem:
In file included from main.cpp:20:0:
recording.h:122:36: error: template argument 2 is invalid
map<string, Filter::Filter*> filters;
^
recording.h:122:36: error: template argument 4 is invalid
which I asked about here.
AN EVEN EASIER SOLUTION - Taking advantage of a new, edited version of sclite
This is in case someone finds the answer here useful. I know there are no votes here, but I just got a trophy telling me this is my first question to get 1000 views, so I'll update my answer to show the easiest way to get things done.
TL;DR
https://www.nist.gov/itl/iad/mig/tools
https://github.com/usnistgov/SCTK
% cd /the/dir/where/i/want/to/install
% git clone https://github.com/usnistgov/SCTK.git
% cd SCTK
From the git master README (quoted) with some comments I've put in.
% make config
% sed -i 's#[-]Os#-m64#g' src/asclite/core/makefile
% sed -i 's#[-]Os#-m64#g' src/asclite/test/makefile
% sed -i 's#[-]Os#-m64#g' src/sclite/makefile
% make clean
% ## Possible edit to the `rfilter1 makefile`, which are
% ## described at the end of the answer but were not necessary
% ## for me.
% make all
% make check
% make install
% make doc
I also add the executables' directory to my PATH and make the documentation available via the man command.
% pwd
/the/dir/where/i/want/to/install/SCTK
% # back up your `.bashrc`
% cp $HOME/.bashrc "${HOME}/.bashrc.$(date +%Y%m%d-%H%M%S).bak"
% # persistent path changes
% echo -e "\n\n## Allow access to sclite, rfilter, etc" >> $HOME/.bashrc
% # your machine might use something other than `export` for this. CHECK!
% echo 'export PATH='"$(pwd)/bin"':$PATH' >> $HOME/.bashrc
% # make changes availabel this session
% source ~/.bashrc
% # man stuff
% cd doc
% cp -r ./* /usr/man/man1
END OF THE TL;DR SECTION
Details
Since when I posted this in May 2018, there have finally been some updates made to the software:
I posted my question in May 2018, and the updates were made in Fall 2018. They partly fix the problems I ran into here, but some of the information in the README and some makefiles are useful to note here.
The 32- to 64- bit issue (changing -Os to -m64, as done above) was find-able via the README.
% cat -n README.md | grep -A 4 "64 bits Compilation"
61 **64 bits Compilation**:
62 With big alignments, sctk needs to be compiled in 64 bits. By default, the C/C++ software are compiled in 32 bits with the options (`-Os`) but can be compiled in 64 bits. To do so, `-m64` is added to the CFLAGS variable in `src/asclite/core/makefile`, `src/asclite/test/makefile`, `src/rfilter1/makefile` and `src/sclite/makefile`.
63
64 Example of `CFLAGS` for OSX 10.4+: `-fast -m64 -arch x86_64 -arch ppc64`
65
Here is line 62 with word wrap
With big alignments, sctk needs to be compiled in 64 bits. By default, the C/C++ software are compiled in 32 bits with the options (-Os) but can be compiled in 64 bits. To do so, -m64 is added to the CFLAGS variable in
src/asclite/core/makefile,
src/asclite/test/makefile,
src/rfilter1/makefile and
src/sclite/makefile.
Since there was no -Os in src/rfilter1/makefile, I didn't make any changes.
I was able to finish the installation with no problem (including no failed tests). Here is my system info.
$ uname -a
CYGWIN_NT-10.0 MyMachine 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
$ bash --version | head -n 1
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin)
$ gcc --version | head -n 1
gcc (GCC) 7.4.0
$ g++ --version | head -n 1
g++ (GCC) 7.4.0
$ make --version | head -n 2
GNU Make 4.2.1
Built for x86_64-unknown-cygwin
$ systeminfo | sed -n 's/^OS\ *//p'
Name: Microsoft Windows 10 Enterprise
Version: 10.0.17134 N/A Build 17134
Manufacturer: Microsoft Corporation
Configuration: Member Workstation
Build Type: Multiprocessor Free
However, it seems that some other people trying to compile on Cygwin have had issues. Here is some more info from the README
% grep "Special Note to Cygwin users" README.md
*Special Note to Cygwin users:* it has been reported that compilation of `rfilter1` can fail in some case, please read the OPTIONS part of the `rfilter1/makefile` and adapt accordingly before retrying compilation.
Well, let's look at the makefile for rfilter1, and see what some of you might need to do.
% head -n 15 src/rfilter1/makefile | tail -7
########################### Options for compilation #########################
####### If you have an very new version of GCC, the strcmp* family of functions
####### is included in the distribution. Changing the value of OPTIONS to
####### be blank will diable the use of supplied versions of these functions.
####### In particular, this behavior has been noted on some versions of cygwin
OPTIONS=-DNEED_STRCMP=1 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
So, if you have rfilter1 compilation problems, change the non-commented line to
OPTIONS= $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)

ld linker error "cpu model hidden symbol"

I'm getting an ld error when attempting to compile an sfml program on ubuntu 16.04. This is apparently a known issue, and there is supposed to be a workaround, but I don't understand what is it...
http://web.archive.org/web/20160509014317/https://gitlab.peach-bun.com/pinion/SFML/commit/3383b4a472f0bd16a8161fb8760cd3e6333f1782.patch
The error spat out by ld is
hidden symbol `__cpu_model' in /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a(cpuinfo.o) is referenced by DSO
There is no relevant code to this - as I understand it this error is produced on all ubuntu 16.04 systems with g++ 5, if the program to be linked contains objects such as sf::Texture and sf::Sprite. (I don't know any more detail than this.)
I have tried also compiling with g++ 4.9, but the same error occurs.
My compile line is g++-4.9 --std=c++11 -Wall main.cpp -lsfml-graphics -lsfml-window -lsfml-system -o a.out
Has anyone else experienced this error and resolved it successfully?
I've had to fix this issue several times. Instead of applying the patch, you can manually fix it by editing the file SFML/src/SFML/Graphics/CMakeLists.txt. At line 149, you will find the following:
if(SFML_COMPILER_GCC)
set_source_files_properties(${SRCROOT}/ImageLoader.cpp PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
endif()
After the endif(), insert the following:
if(SFML_COMPILER_GCC AND BUILD_SHARED_LIBS)
list(APPEND GRAPHICS_EXT_LIBS "-lgcc_s -lgcc")
endif()
Then, in the top-level SFML folder, run the following:
mkdir build && cd build
cmake .. -DSFML_BUILD_EXAMPLES=ON -DSFML_BUILD_DOCS=ON
make
sudo make install
sudo ldconfig
This will get it built and installed without the compiler error. (Note: Remove the -D flags from cmake if you don't want docs or examples)
I ran this in the SFML source directory before running the standard cmake...make:
curl https://gitlab.peach-bun.com/pinion/SFML/commit/3383b4a472f0bd16a8161fb8760cd3e6333f1782.patch \
| patch -p1
and that solved the problem
I've got the same linker error when trying to build SFML 2.4.2 with examples, specifically with opengl and shader ones.
Inspired by the #Joshua solution, I tried to change the compiler from GCC to Clang. It worked.
I am sharing here because it seems to be a simpler solution if you have no restrictions to use Clang.
Just download SFML and change to its directory. And...
mkdir build && cd build
cmake .. -DSFML_BUILD_EXAMPLES=ON -DCMAKE_CXX_COMPILER=clang++
make
sudo make install
sudo ldconfig
Removing -fvisibility=hidden from compiler options worked for me.

codeblocks can't open g++

I'm currently running ubuntu 13.10 with codeblocks and when I try to build it comes up with this message:
g++ -c /home/rhys/Documents/Progamming/c++/Class_private/main.cpp -o /home/rhys/Documents/Progamming/c++/Class_private/main.o
/bin/sh: 0: Can't open g++ -c /home/rhys/Documents/Progamming/c++/Class_private/main.cpp -o /home/rhys/Documents/Progamming /c++/Class_private/main.o
Process terminated with status 127 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)
It used to work fine but it does not work now, I have downloaded the build-essential, then the gcc complier which it is set to in the settings.
Can anyone help??
check "Settings -> Environment -> General settings -> Shell to run commands in:" and make sure it says "/bin/sh -c" you must have the -c argument. Either this or it could a file path problem with the compiler or source files themselves.
I think you must set the access for your files and/or your whole working directory. So go there, and change permission with chmod:
cd /home/rhys/Documents/Progamming/c++/Class_private/
chmod 755 *
If this not works maybe you should check if g++ is accessible. Run:
g++ --version
See if it prints the information or another error.
Another solution could be to open Code::Blocks as a superuser and then try again as you normally did.

"make[2]: g++: Command not found" in Netbeans

I get the error message:
make[2]: g++: Command not found
which I know means it cannot find the C++ compiler. However, in Netbeans if I go to the configuration to choose my C++ compiler it shows the following being in /usr/bin:
g++4.6
g++4.7
g++4.8
but it doesn't have just g++.
Tried sudo aptitude install g++ but it didnt work.
If I do g++ --version I get:
The program 'g++' can be found in the following packages:
* g++
* pentium-builder
1) Verify you can run "g++" from the command line,
2) type whereis g++ to get the path,
3) Make sure you have the NetBeans C++ plugin installed
Go to Tools->Options->C++->Build Tools
4) Configure the path in NetBeans
Usually, /usr/bin/g++ is a symlink to some /usr/bin/g++-4.7 (or g++-4.8 etc...); just make it again (which is usually provided by the g++ virtual package on Debian or Ubuntu), e.g.
% sudo -s
# cd /usr/bin
# ln -sv g++-4.8 g++
Above % and # are shell prompts that you should not type.
Of course, don't forget the sudo apt-get install g++ etc...
BTW, you might put that link from $HOME/bin/g++ to /usr/bin/g++-4.8 and you don't need root permission for that.
(sometimes, these symlinks go indirectly thru /etc/alternatives etc...)
Your issue is a sysadmin issue; you should rather ask it (with a big lot more details) on askubuntu or superuser; it is off-topic on Stack Overflow.
BTW, NetBeans is not a compiler, but an editor (sometimes called IDE). You could use something better/simpler (e.g. emacs or vim) with e.g. make as a builder (to be run inside a terminal). Before using NetBeans ensure that g++ -v is working alone in some terminal