codeblocks can't open g++ - c++

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.

Related

How do you run and compile C++ code on alpine linux?

I’m new to alpine linux, and I’ve been trying to use it to run and compile C++ code, but I can’t get it to run the code.
First, I put the code in the opt folder, than I did this:
cd / → cd opt → clang++ -S -emit-llvm myFile.cpp
That created myFile in the opt folder, then I tried to use
sh myFile
To run the code, but it said “no such file or directory found,” If I do sh myFile.cpp, I get a few errors.
What am I doing wrong here?
Some of the packages I have installed are build-base, and clang.
By default, the result of clang (clang++ as well) is saved to a.out file, so you may run ./a.out or sh a.out. If you want to change output, use -o <filename> in clang command

How to create alpha_encoder.exe (webm-tools) under msys2?

I'm trying to compile alpha_encoder) (little utility of The WebM Project, under webm-tools).
I have a previous installation of msys2 (downloaded and configured by build_locally_with_various_option_prompts.bat) under c:\FFcompiler. It took its time, but I managed to compile ffmpeg, so I decided to use it (I think it will do). That's what I've done till now.
First, I cloned webm-tools under /cygdrive/c/FFcompiler/ffmpeg_local_builds/sandbox/win32/libvpx-1.4.0/third_party/. There's a Makefile so I tried to run make:
$ cd /cygdrive/c/FFcompiler/ffmpeg_local_builds/sandbox/win32/libvpx-1.4.0/third_party/
$ git clone https://chromium.googlesource.com/webm/webm-tools.git
$ cd webm-tools/alpha_encoder/
$ make
But g++ complains mkvparser.hpp doesn't exist. The command is
g++ -c -W -Wall -O3 -g -I../../libwebm alpha_encoder.cc -o alpha_encoder.o
After searching the web, it seems that webm-tools depends on libwebm, and expect finding it as a sibling folder of webm-tools. So...
$ cd ../..
$ git clone https://chromium.googlesource.com/webm/libwebm.git
$ cd libwebm
Now, what? README.libwebm tells that 'to cross compile libwebm for Windows using mingw-w64' first I must run cmake like this cmake -DCMAKE_TOOLCHAIN_FILE=path/to/libwebm/build/mingw-w64_toolchain.cmake path/to/libwebm. In my case:
cmake -DCMAKE_TOOLCHAIN_FILE=build/mingw-w64_toolchain.cmake .
And cmake cannot find i686-w64-mingw32-g++. After googling more, it seems the easiest way to fix this is to add bin of mingw-w64-i686 to PATH.
$ export PATH=/cygdrive/c/FFcompiler/ffmpeg_local_builds/sandbox/cross_compilers/mingw-w64-i686/bin:$PATH
After this, now cmake finishes successfully and creates a Makefile, but make stops with an error:
/cygdrive/c/FFcompiler/ffmpeg_local_builds/sandbox/win32/libvpx-1.4.0/third_part
y/libwebm/common/file_util.cc:44:39: error: 'tmpnam_s' was not declared in this
scope
errno_t err = tmpnam_s(tmp_file_name);
^
I've searched about the error but I'm stuck. What am I missing?

gcc error trying to exec 'cc1': execvp: No such file or directory when running with non-root user

I see that same question has been asked many times but my problem is different.
I installed gcc on ubuntu 14.04 and and it works fine with root user.
When I attempt to compile using non-root user it throws
error gcc: error trying to exec 'cc1': execvp: No such file or
directory
Once I compile the file with root user, non-root user is able to execute the file without any error but it is not able to compile the file.
I suspect there is a problem with file permissions and I have checked permissions for cc1 and non root user had execute permission on the file.
First way:
Under the root account use the command:
which gcc
which cc1
ls -l $Output of previous command
It will show you where are cc1 and gcc and rights of cc1
Check that you have proper rights for cc1 file
Then under "regular" user:
which gcc
Output of which gcc should be the same as for root.
If right is ok and path to gcc the same as under the root, add PATH to cc1 for user.
Second way:
Under the root account:
gcc -v hello_world.c 2>&1 | grep cc1
And do the same under the "regular" account.
It will show you the real commands that was used for compilation.
Compare them and check rights and PATH as in first way
To add PATH use: export PATH=$PATH:$add_new_path_to_folder_here
In my case, this error was occurring while attempting to compile an updated version of ffi, nokogiri and other gems on Ubuntu. gcc -v revealed I was using gcc and g++ 4.8.
The fix was to switch my gcc/g++ symlinks to use 4.9 instead of 4.8.
$ which gcc
$ ls -ld /usr/local/bin/gcc
$ sudo rm /usr/local/bin/gcc
$ sudo ln -s /usr/bin/gcc-4.9 /usr/local/bin/gcc
$ ls -ld /usr/local/bin/gcc
Repeat for g++.

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

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.

Flymake Configuration Error in Ubuntu Emacs (C++ mode)

I have been trying to set up fly-make on my system. But it hasn't been working.
I have a C++ file called advancedFunctions.cpp and a have a Makefile in the directory where my .cpp file is housed. My Makefile contains this:
check-syntax:
g++ -o nul -S $(CHK_SOURCES)
advancedFunctions:
g++ -o advancedFunctions advancedFunctions.cpp
Whenever I invoke flymake via M-x flymake, it give this error:
Flymake: Configuration Error has occurred while running (make -s -C ./ CHK_SOURCES=advancedFunctions_flymake.cpp SYNTAX_CHECK_MODE=1 check-syntax). Flymake will be switched off.
What can I do about this? Hints, please.