Questions tagged [gcc]

GCC is the GNU Compiler Collection. 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.

GCC is the GNU Compiler Collection, a collection of free software compilers. It is a key component of the GNU Toolchain.

GCC includes an optimizing C compiler that is the most commonly used C compiler on Linux. GCC also includes front ends for C++ (including full support for C++17), Objective-C, Fortran, Ada, and Go, as well as libraries for these languages (libstdc++, libgfortran, ...). It supports many architectures.

GCC sources are available via the Git repository. Major decisions about GCC are made by the steering committee, guided by the mission statement.

See also GCC online documentation and the home page, and release dates.

40905 questions
239
votes
1 answer

std::vector performance regression when enabling C++11

I have found an interesting performance regression in a small C++ snippet, when I enable C++11: #include struct Item { int a; int b; }; int main() { const std::size_t num_items = 10000000; std::vector container; …
milianw
  • 5,164
  • 2
  • 37
  • 41
234
votes
6 answers

How do I install imagemagick with homebrew?

I'm trying to install Imagemagick on OSX Lion but something is not working as expected. -> brew install imagemagick /usr/local/git/bin/git ==> Cloning https://github.com/adamv/ImageMagick.git Cloning into…
Kleber S.
  • 8,110
  • 6
  • 43
  • 69
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
233
votes
11 answers

Multiple glibc libraries on a single host

My linux (SLES-8) server currently has glibc-2.2.5-235, but I have a program which won't work on this version and requires glibc-2.3.3. Is it possible to have multiple glibcs installed on the same host? This is the error I get when I run my program…
dogbane
  • 266,786
  • 75
  • 396
  • 414
232
votes
3 answers

Realistic usage of the C99 'restrict' keyword?

I was browsing through some documentation and questions/answers and saw it mentioned. I read a brief description, stating that it would be basically a promise from the programmer that the pointer won't be used to point somewhere else. Can anyone…
user90052
  • 2,550
  • 3
  • 16
  • 7
232
votes
14 answers

Objective-C for Windows

What would be the best way to write Objective-C on the Windows platform? Cygwin and gcc? Is there a way I can somehow integrate this into Visual Studio? Along those lines - are there any suggestions as to how to link in and use the Windows SDK for…
Luther Baker
  • 7,236
  • 13
  • 46
  • 64
224
votes
1 answer

Build .so file from .c file using gcc command line

I'm trying to create a hello world project for Linux dynamic libraries (.so files). So I have a file hello.c: #include void hello() { printf("Hello world!\n"); } How do I create a .so file that exports hello(), using gcc from the…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
219
votes
10 answers

Where does gcc look for C and C++ header files?

On a Unix system, where does gcc look for header files? I spent a little time this morning looking for some system header files, so I thought this would be good information to have here.
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
217
votes
5 answers

Differences between arm64 and aarch64

I have two "unlocked" devices, an iPad mini 3, and a Galaxy Edge 6, both endowed with a terminal and a minimalistic set of unix commands. I thought both devices have arm64 processors but when I ran uname -a on both devices I got the following : for…
Olórin
  • 3,367
  • 2
  • 22
  • 42
213
votes
8 answers

Is errno thread-safe?

In errno.h, this variable is declared as extern int errno; so my question is, is it safe to check errno value after some calls or use perror() in multi-threaded code. Is this a thread safe variable? If not, then whats the alternative ? I am using…
Vinit Dhatrak
  • 6,814
  • 8
  • 27
  • 30
212
votes
5 answers

How to generate gcc debug symbol outside the build target?

I know I can generate debug symbol using -g option. However the symbol is embeded in the target file. Could gcc generate debug symbol outside the result executable/library? Like .pdb file of windows VC++ compiler did.
kcwu
  • 6,778
  • 4
  • 27
  • 32
209
votes
2 answers

What does gcc's ffast-math actually do?

I understand gcc's --ffast-math flag can greatly increase speed for float ops, and goes outside of IEEE standards, but I can't seem to find information on what is really happening when it's on. Can anyone please explain some of the details and maybe…
Ponml
  • 2,917
  • 5
  • 20
  • 17
209
votes
11 answers

"/usr/bin/ld: cannot find -lz"

I am trying to compile Android source code under Ubuntu 10.04. I get an error saying, /usr/bin/ld: cannot find -lz Can you please tell me how can I fix it? What does cannot find -lz mean? Here's the full error…
michael
  • 106,540
  • 116
  • 246
  • 346
206
votes
4 answers

LD_LIBRARY_PATH vs LIBRARY_PATH

I'm building a simple C++ program and I want to temporarily substitute a system supplied shared library with a more recent version of it, for development and testing. I tried setting the LD_LIBRARY_PATH variable but the linker (ld) failed…
Georgios Politis
  • 2,610
  • 3
  • 19
  • 10
203
votes
7 answers

Make install, but not to default directories?

I want to run 'make install' so I have everything I need, but I'd like it to install the things in their own folder as opposed to the system's /usr/bin etc. is that possible? even if it references tools in the /usr/bin etc.?
Jon Phenow
  • 3,974
  • 5
  • 26
  • 30