I am learning C++ and I need to properly setup my compile and build commands in Geany for C++11.
I thought I had them correct, but when using auto, I receive the following error:
warning: ‘auto’ will change meaning in C++0x; please remove it [-Wc++0x-compat]
Here are my current set build commands:
Compile: g++ -Wall -c "%f"
Build: g++ -Wall -o "%e" "%f"
Execute: "./%e"
What do I need to set these to in order to properly compile, build, and execute a C++11 program?
As what is pointed out in the comments, you need to add the flag -std=c++0x. You can set it in the "Build" -> "Set build commands", then modify the commands in following boxs:
Compile:
g++ -Wall -std=c++0x -c "%f"
Build:
g++ -Wall -std=c++0x -o "%e" "%f"
Related
I would like to append flags to the compiler flags when running make, without altering the Makefile in anyway, e.g.
make CXX_FLAGS+='-DDEBUG'
The above treats "+=" as "=", so it's not the correct symbol.
You just have to modify the variable as override in your Makefile once. And then you can do what you want to do.
Here's the example,
Makefile:
override CFLAGS+=-g
app: main.c
gcc $(CFLAGS) -o app main.c
Run the make:
$ make
gcc -g -o app main.c
Append the '-Wall' to $CFLAGS from the command:
$ make CFLAGS=-Wall
gcc -Wall -g -o app main.c
Work fine here. And here's manual you can reference.
As in the title, when I try to compile an object file using g++ by running this shell script:
#!/bin/bash
name=textsweeper
srcdir=src
buildir=build
cc=g++
cppflags=-Wall -std=c++11 -ggdb -O
libs=
rm -f $buildir/$name $buildir/main.o
$cc $cppflags $srcdir/main.cpp -c -o $buildir/main.o
$cc $buildir/main.o $libs -o $buildir/$name
I get the following error:
$ bash compile
compile: line 6: -std=c++11: command not found
And other errors about things being only available only with stdc++11.
I've tried yahooing the error, but I've only got answers to about errors about actual command not arguments.
Variable assignment is space sensitive. Change:
cppflags=-Wall -std=c++11 -ggdb -O
to
cppflags="-Wall -std=c++11 -ggdb -O"
Otherwise, you're trying to run the command -std=c++11 -ggdb -O with the environment including a setting of cppflags=-Wall. bash allows temporary environment settings to be done this way, which is why its important to quote any variable assignments that contain spaces.
I have Jgrasp set up and running fine with c++. I want to use c++11. I get the following compile error:
gift1.cpp:52:24: warning: range-based 'for' loops only available with -std=c++11 or -std=gnu++11
Which I attempt to solve by clicking Settings, compiler settings, workspace. I copied my environment settings "g++ - generic" and renamed it "user: g++ - generic." I then clicked edit. I changed the original compile code:
g++ %<CY> %<D> -g %<D> -c -o %<RELE_DEF_BIN_DIR>%<base>.o %<> %<REL_FILE>
to
g++ %<CY> %<D> -g %<D> -c -o -std=c++11 %<RELE_DEF_BIN_DIR>%<base>.o %<> %<REL_FILE>
But it still gives the same error. (I added "-std=c++11".)
Edit: I have changed the string to
g++ -std=c++11 %<CY> %<D> -g %<D> -c -o %<RELE_DEF_BIN_DIR>%<base>.o %<> %<REL_FILE>
but have the same problem. I agree with the comment that this just doesn't appear to be modifying my build commands at all. When I compile, it outputs:
jGRASP exec: g++ -g -o gift1.exe gift1.cpp
I’m running Netbeans 7.4 on Mavericks. In order to be able to use gdb, compilation with the -ggdb flag seems to be necessary. However, even though I specify it through the Project’s Properties/Additional Options wizard, Netbeans also emits -g during compilation. Unfortunately, it turns out that this behavior has an adverse effect when the debugging session commences. Is there any way to force Netbeans not to also emit -g?
Output during compilation:
g++ -m64 -ggdb -c -g -Werror -std=c++11 -MMD -MP -MF "build/Debug/macport_GNU-MacOSX/main.o.d" -o build/Debug/macport_GNU-MacOSX/main.o main.cpp
mkdir -p dist/Debug/macport_GNU-MacOSX
g++ -m64 -ggdb -o dist/Debug/macport_GNU-MacOSX/executable build/Debug/macport_GNU-MacOSX/main.o
Alexander.Simon#oracle.com responded here [1] to set "Development Mode" to "No Flags", then specify -ggdb in the "Additional Options".
1 - https://netbeans.org/projects/cnd/lists/users/archive/2014-02/message/12
I have a warning involving /usr/local/lib/gcc/x86_64-apple-darwin10.8.0/4.6.4/libgcc.a. I was trying to compile a C++ project using a Makefile, which shows the following:
executeit: bplustree.o nonleafnode.o leafnode.o
g++ -o executeit bplustree.o nonleafnode.o leafnode.o
bplustree.o: bplustree.cpp
g++ -g -c bplustree.cpp
nonleafnode.o: nonleafnode.h nonleafnode.cpp
g++ -g -c nonleafnode.h nonleafnode.cpp
leafnode.o: leafnode.h leafnode.cpp
g++ -g -c leafnode.h leafnode.cpp
clean:
rm executeit bplustree.o nonleafnode.o leafnode.o
When I invoke "make", I get the following output in Terminal:
g++ -g -c bplustree.cpp
g++ -g -c nonleafnode.h nonleafnode.cpp
g++ -g -c leafnode.h leafnode.cpp
g++ -o executeit bplustree.o nonleafnode.o leafnode.o
ld: warning: in /usr/local/lib/gcc/x86_64-apple-darwin10.8.0/4.6.4/libgcc.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
As you can see, I have gcc version 4.6.4. I am not sure if this warning is a threat to the project working in any way, but I would like to know what this warning means and if it is a threat. It would be nice if I can do something to remove it, too. Thank you.
I have Mac OS X Version 10.6.8. The file /usr/local/lib/gcc/x86_64-apple-darwin10.8.0/4.6.4/libgcc.a has "10.8.0", and this version of gcc I installed must have screwed me over. I don't know if I can remove this warning by installing OS X 10.8.0, but I will consider this question answered for now. Thank you.