I've used CodeRunner (http://krillapps.com/coderunner) for a long time but recently I can't compile any C or C++ code in it. This started happening around the time I updated to Xcode 5.1. I can still compile and run as normal in Xcode.
When I try to run in CodeRunner, the following error is printed.
clang: error: unknown argument: '-finput-charset=UTF-8' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
There is already a solution for Objective C:
Clang error when compiling in CodeRunner
Does anyone know how to modify the script for C++/ C?
Thanks in advance.
There is a similar bug with the object-c compilation, the link to fix that is
Clang error when compiling in CodeRunner,
and you just need do as below for the c/c++ situation:
g++ "$1" -o "$compname" -finput-charset=${enc[$2]} $3
g++ "$1" -o "$compname" $3
Related
The full terminal output is as follows:
>g++ -std=c++98 -static mainP1.o -o mainP1
>
>ld: library not found for -lcrt0.o
>
>clang: error: linker command failed with exit code 1 (use -v to see invocation)
>
>make: *** [mainP1] Error 1
I'm on a 2020 MacBook Pro with an intel CPU using Visual Studio Code. When I write basic OOP programs in C++ it compiles fine without any clang errors. However, when working with big OOP programs with multiple classes inheriting from a base class I would get this error.
I tried searching online for solutions, but no solution or explanation was found. I double-checked my makefile to ensure I was not linking classes incorrectly.
I thought maybe I should just dual-boot with UBUNTU Linux to avoid this weird XCODE issue I was encountering with clang, but that was also a fruitless endeavor.
The problem was my compiler path in Visual Studio Code.
I changed it to clang++, and now all my code compiles and executes without any problems.
How I changed it:
CMD + SHIFT + P
Typed in: C/C++: Edit Configurations (UI)
Made sure that "Mac" was selected under configuration name.
Changed Compiler Path to: /usr/bin/clang++
I am pretty new to VSCode. I use code-runner extension to run C++ program and strangely it does not tell me exactly which line caused the error. How should I know it?
For example the error message will look like this
/bin/sh: line 1: 87002 Segmentation fault: 11 "/my/path"
I would suggest that you choose from Visual Studio Code the option Terminal > New Terminal and manually compile your source file with something similar to the following:
c++ -Wall -Werror -Wextra -g -fsanitize=address <your_file_here.c>
The compilation will fail if there is any warning/error/etc. caught by the compiler.
Recently, I am trying to compile a project with a dependency package called "dealii", but I keep getting this error when compiling:
g++: error: unrecognized command line option '-Wplacement-new'
It seems that g++ does not recognize the option -Wplacement-new. Then I looked at the documentation for gcc, it says -Wplacement-new is a legal warning option flag. But when I invoke "gcc -Wplacement-new ./a.c" I still get this kind of error.
My g++, etc are the latest version. Does anyone know how to fix it? Thanks
I am using c++ 11 i guess as per code::blocks. I was looking for a way to update to C++ 14. I found a way on one of the threads where it told me to add a flag in the compiler settings
-std=c++14
My default compiler is set to GNU GCC.
However after i tested a C++ 14 feature program it showed me the following error:
error: unrecognized command line option '-std=c++14'
Can anyone help me with this ? I was unable to find a solution online.
Also if what i did was wrong , is there any other way to switch to C++ 14?
I am trying to compile a c++ program in Linux, using the command in the shell
$ g++ -Wall *.cpp -o prog
and for some reason it keeps on giving me a weird error:
g++: Internal error: Bus error (program cc1plus) Please submit a full
bug report. See for
instructions.
I searched the net for this bus error, and it says that it has to do with something about accessing illegal memory.
Can someone maybe clarify things a bit more for me?
This error message is telling you that there's a bug in the g++ compiler itself.
Try to narrow it down by removing bits and pieces of your source file until the problem goes away. You're not trying to fix your program, you're just trying to find the part that is breaking the compiler. Once you've found it, you can either give a better bug description or you can change your code to work around it.
Or just download the latest version of the g++ compiler and hope that it's already fixed.
Your problem is not in your code, is the compiler (g++) that is crashing and producing that Bus Error, it's possible you have an outdated version of such compiler and need to update, or you're lucky and found a real bug in g++.
I would try compiling each source file separately, to check what part of the source code triggers the error.