Category "gcc"

Attempting to compile with my own static C library

I compiled a static library. I have two files. mylib_1.c with function foo1 in it mylib_2.c with function foo2 in it. Both #include "mylib.h". I compiled a libr

Cross Compile zlib for ARM

I try cross compile zlib for arm-poky-linux-gnueabi but I've an error when I launch make : ...:~/zlib-1.2.11$ AR=$HOST-ar CC=$HOST-gcc RANLIB=$HOST-ranlib ./co

Cross Compile zlib for ARM

I try cross compile zlib for arm-poky-linux-gnueabi but I've an error when I launch make : ...:~/zlib-1.2.11$ AR=$HOST-ar CC=$HOST-gcc RANLIB=$HOST-ranlib ./co

Why are the results of the optimization on aliasing different for char* and std::string&?

void f1(int* count, char* str) { for (int i = 0; i < *count; ++i) str[i] = 0; } void f2(int* count, char8_t* str) { for (int i = 0; i < *count; ++i)

What do the values of the C++ "feature test macros" mean?

To test for a feature, cppreference mentions these feature test macros: link. If the feature is present in the compiler, the macro is defined. But I don't unde

Error building program using gcc plugin from linux kernel source tree

I am trying to use a grsecurity gcc plugin that I found on their unofficial linux kernel source tree (the respectre_plugin/ one). My GCC version is 4.7, I modif

Compiling c++ OpenACC parallel CPU code using GCC (G++)

When trying to compile OpenACC code with GCC-9.3.0 (g++) configured with --enable-languages=c,c++,lto --disable-multilib the following code does not use multipl

Would the compiler optimize this for loop?

In C or C++, if the compiler encounters a for loop in which a counter is counting from 0 to n, and n is a variable (not a function call, and NOT A CONSTANT eith

gcc cross compiling for raspberry pi /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.34' not found

On Ubuntu 22.04 LTS, I'm cross-compiling for raspberry pi. When I run any built executable on the pi, I get this linking error: /lib/arm-linux-gnueabihf/libc.so

How can I make sure `iostream` is available to the linker?

I have the following C++ code in a file called helloworld.cpp: #include<iostream> int main() { std::cout << "Hello, World!\n"; } I would like

Use macro definitions (e.g. M_PI) in math.h as float not double

I noticed that all the mathematical constants are declared as double, which leads to conversion problems on some platforms where no double precision units exist

How do I properly pass command line arguments to a C program in CLion?

I need someone to outline how to pass command line arguments to CLion. What I've found so far hasn't worked for me. Specifically I need to know how to pass mult

Why does ld need /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 while its default dynamic linker is /lib64/ld-linux-x86-64.so.2?

In x86-64 target Debian, most of the programs are link against shared objects with the /lib64/ld-linux-x86-64.so.2. And there is also one in /lib/x86_64-linux-g

C++ union struct with struct member works on Clang and MSVC but not GCC

I am trying to define a union struct with some struct and primitive members overlapping in memory with a simple array. This works perfectly in Clang and MSVC, b

undefined reference to `__imp___gmpz_init', building GMP program on Cygwin

I'm trying to compile this simple GMP program on Cygwin: #include <gmp.h> int main(){ mpz_t i; mpz_init(i); } This is the command: gcc -lgmp t

Explaining "g++ not found in PATH" for an idiot

So, I just installed Eclipse for C/C++ and whenever I make a new project, I get two errors saying that the programs g++ and gcc are not in my PATH. All of the a

The procedure entry point _ZNSt7_cxx1112basic_stringlcSt11char_traitslcESalcEEC1Ev could not be located in the dynamic link library

I am having immense difficulty trying to use std::string. The program compiles absolutely fine, but when I run the program, I receive this error: error I have

/usr/bin/ld: final link failed: Illegal seek collect2: ld returned 1 exit status

I am running my program on linux server and it was compiling and running fine then i made another directory and tried to compile it in that directory and it w

How to include omp.h in OS X?

I'm new in C and have some problems compiling my code in OS X. I code Java a lot both in Eclipse and use terminal to compile my code. However now I'm learning

Is there a direct way to get clear details on gcc acceptable option values (e.g. for -std) without grep-ing through irrelevant material?

The gcc (or g++) compiler has a -std option to specify the language standard to use for compiling C or C++. At the top level one can see that this option exists