Questions tagged [g++]

g++ is the C++ frontend to the GNU Compiler Collection (GCC). It's the de facto standard compiler for C, C++, Go, Fortran, and Ada on Linux and supports many other languages and platforms as well. Apart from the compiler, GCC has a toolchain (libc, libstdc++, objdump, nm etc.) that is widely used on several platforms and systems.

G++ is the compiler in the GNU Compiler Collection, .

G++ implements most of C++98/C++03 and in recent releases also supports most of C++11. It ships with the GNU implementation of the C++ standard library, . Like the rest of GCC, it is free software and runs on a wide range of operating systems and architectures.

See also GCC online documentation.

10452 questions
1145
votes
10 answers

What is the difference between g++ and gcc?

What is the difference between g++ and gcc? Which one of them should be used for general c++ development?
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
638
votes
14 answers

usr/bin/ld: cannot find -l

I'm trying to compile my program and it returns this error : usr/bin/ld: cannot find -l in my makefile I use the command g++ and link to my library which is a symbolic link to my library located on an other directory. Is there an…
ZoOo
  • 6,383
  • 3
  • 13
  • 5
533
votes
21 answers

Undefined reference to vtable

When building my C++ program, I'm getting the error message undefined reference to 'vtable... What is the cause of this problem? How do I fix it? It so happens that I'm getting the error for the following code (The class in question is…
RyanG
  • 6,773
  • 5
  • 25
  • 24
425
votes
6 answers

Compiling C++11 with g++

I'm trying to update my C++ compiler to C++11. I have searched a bit and I have come to the conclusion that I have to use the flag -std=c++0x or -std=gnu++0x, but I don't know many things about flags. Can anyone help me? (I'm using Ubuntu…
Rontogiannis Aristofanis
  • 8,883
  • 8
  • 41
  • 58
404
votes
7 answers

C++ unordered_map using a custom class type as the key

I am trying to use a custom class as key for an unordered_map, like the following: #include #include #include using namespace std; class node; class Solution; class Node { public: int a; int b; …
Alfred Zhong
  • 6,773
  • 11
  • 47
  • 59
300
votes
6 answers

GCC dump preprocessor defines

Is there a way for gcc/g++ to dump its default preprocessor defines from the command line? I mean things like __GNUC__, __STDC__, and so on.
Anycorn
  • 50,217
  • 42
  • 167
  • 261
289
votes
5 answers

Is optimisation level -O3 dangerous in g++?

I have heard from various sources (though mostly from a colleague of mine), that compiling with an optimisation level of -O3 in g++ is somehow 'dangerous', and should be avoided in general unless proven to be necessary. Is this true, and if so, why?…
Matt Dunn
  • 5,106
  • 6
  • 31
  • 55
276
votes
7 answers

gcc warning" 'will be initialized after'

I am getting a lot of these warnings from 3rd party code that I cannot modify. Is there a way to disable this warning or at least disable it for certain areas (like #pragma push/pop in VC++)? Example: list.h:1122: warning: `list
LK__
  • 6,515
  • 5
  • 34
  • 53
274
votes
18 answers

g++ undefined reference to typeinfo

I just ran across the following error: (.gnu.linkonce.[stuff]): undefined reference to [method] [object file]:(.gnu.linkonce.[stuff]): undefined reference to `typeinfo for [classname]' Why might one get one of these "undefined reference to…
cdleary
  • 69,512
  • 53
  • 163
  • 191
271
votes
14 answers

to_string is not a member of std, says g++ (mingw)

I am making a small vocabulary remembering program where words would would be flashed at me randomly for meanings. I want to use standard C++ library as Bjarne Stroustroup tells us, but I have encountered a seemingly strange problem right out of the…
Anurag Kalia
  • 4,668
  • 4
  • 21
  • 28
234
votes
1 answer

Disable all gcc warnings

I'm working on a project that will read compiler error messages of a particular variety and do useful things with them. The sample codebase I'm testing this on (a random open-source application), and hence rebuilding frequently, contains a few bits…
Phil Miller
  • 36,389
  • 13
  • 67
  • 90
232
votes
6 answers

How to make a variadic macro (variable number of arguments)

I want to write a macro in C that accepts any number of parameters, not a specific number example: #define macro( X ) something_complicated( whatever( X ) ) where X is any number of parameters I need this because whatever is overloaded and can be…
hasen
  • 161,647
  • 65
  • 194
  • 231
224
votes
10 answers

Missing include "bits/c++config.h" when cross compiling 64 bit program on 32 bit in Ubuntu

I am running the 32bit version of Ubuntu 10.10 and trying to cross compile to a 64 bit target. Based on my research, I have installed the g++-multilib package. The program is a very simple hello world: #include int main( int argc, char**…
Jesse Vogt
  • 16,229
  • 16
  • 59
  • 72
216
votes
9 answers

Undefined reference to static class member

Can anyone explain why following code won't compile? At least on g++ 4.2.4. And more interesting, why it will compile when I cast MEMBER to int? #include class Foo { public: static const int MEMBER = 1; }; int main(){ …
Pawel Piatkowski
  • 2,359
  • 3
  • 15
  • 8
211
votes
11 answers

How do I install g++ for Fedora?

How do I install g++ for Fedora Linux? I have been searching the dnf command to install g++ but didn't find anything. How do I install it? I have already installed gcc
saplingPro
  • 20,769
  • 53
  • 137
  • 195
1
2 3
99 100