r/gcc • u/unixbhaskar • Jan 31 '23
GCC’s -O3 Can Transform Performance
sunnyflunk.github.ioWhat is the best debugger for linux?
I saw one that looks white and orange, kinda retro looking, what is it called?
r/gcc • u/android-google-user • Nov 24 '19
All I did was hello world what the hell is this error
r/gcc • u/9-Cortes • Feb 28 '20
Compiling custom header?
Why to compile a custom header behave like this:For example:
"msg.h" file:
#ifndef MSG_H
#define MSG_G
void message();
#endif
---------------------------------------------
"msg.cpp"file
#include "msg.h"
#include <iostream>
void message()
{
std::cout << "Hello World" << std::endl;
}
----------------------------------------------
mainCode.cpp file
#include "msg.h"
#include <iostream>
int main()
{
message();
return 0;
}If I try to compile this code like this: g++ -o mainCode.exe mainCode.cpp
I get an error about ld "undefined referrence" do message(). It seems the linker dont find the msg.cpp file.
To make it work I have to compile it with: g++ -o mainCode.exe mainCode.cpp msg.cpp
The case is that Im trying to create a custom header so why do I have to include the msg.cpp in the compiler command but to all default system headers I dont have to add the header's name in command line to compile?
How can I make my custom header work like other librarys like stdio.h or iostream etc? I would like to be able to just use an #include statement and my custom header work. This situation is really annoying because I would like to create a precompiled header.
r/gcc • u/tadm123 • Aug 18 '16
'make' is not being recognized as an internal or external command
What can I do get it to recognize it or install 'make' separately?
r/gcc • u/pocketmypocket • Apr 14 '22
I'm trying to compile gcc, when I run 'gcc main.c' I get an error that its missing '#include "config.h" '
I can confirm there is no config file in the folder that I FTP'd off the GNU website.
Where am I supposed to get this?
r/gcc • u/EternalSeekerX • Jun 02 '21
Trying to compile GCC-5.5 on Fedora 34
Hello everyone,
So I am trying to compile Gcc-5.5 on Fedora 34 to be used for compiling foam extend 4.0. I am having an issue regarding this error:
../../gcc-5.5.0/gcc/reload1.c: In function ‘void init_reload()’:
../../gcc-5.5.0/gcc/reload1.c:115:24: error: use of an operand of type ‘bool’ in ‘operator++’ is forbidden in C++17
115 | (this_target_reload->x_spill_indirect_levels)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~My system gcc is 11 currently. Is it possible to compile 5.5 using my newer compiled 7.5? Or is there a patch I need to do?
Edit: I assume when I run configure I can use CC and CXX to point to the gcc-7.5?
Edit 2: Yep, its currently compiling, will wait to see if its a success.
r/gcc • u/[deleted] • Dec 01 '20
Do you need to delete previously compiled file before recompiling?
As said in the title, if I compiled a file into a.exe, if I wish to re-compile my file, do I need to delete the a.exe first, or does GCC take care of that?
r/gcc • u/mywenislong • Nov 02 '22
What does this error mean
g++.exe: error: -E or -x required when input is from standard input
I googled everywhere for this error, however nothing comes up on it. Some help would be nice pals.
r/gcc • u/boydbuilding • Feb 29 '20
how to specify the cc1 to use which gcc?
Hi,
currently, type:
$cc -v
gcc version 4.4.7but type
$gcc --version
gcc (GCC) 8.2.0and the cc cannot work with such commands:
/usr/bin/cc -O3 -g3 -fno-tree-loop-distribute-patternsit causes error with
cc1: error: unrecognized command line option "-fno-tree-loop-distribute-patterns"is it because the cc version is way too old?
is there a way to build or make the code with a specified gcc like the 8.2 version?
thanks a ton
r/gcc • u/mixython • Jul 17 '21
error gcc: undefined reference to symbol '__getauxval@@GLIBC_2.17'
Hello everybody. I am trying to compile simple C code but I am getting this error. Stack Overflow
r/gcc • u/ConflictNovel2866 • Dec 10 '23
GCC is version 6.3.0 and doesnt update via mingw?
I tried updating GCC via console and via GUI but both didn't update my gcc. Can i reinstall it without breaking anything or how do i solve this issue?
(and yes i made sure to update AND upgrade)
r/gcc • u/abundantmind • Dec 06 '15
Help: Why isn't make working?
Hi, I've just installed the GCC compiler and am trying to use a makefile so I don't have to type enormous gcc command lines every time I want to recompile.
But I keep getting "make" command not found.
And there is no "make.exe" in the "bin" directory.
Has the "make" exe and makefile requirement been deprecated?
r/gcc • u/BurnyAsn • Aug 20 '25
Why would a vector element get processed more than once in this code?
Here is my code I just began writing. The colorful function does almost nothing to interfere with the values of int i and vector<int> A since both are out of scope and no references passed.
The loop is also pretty straight forward. And yet the printing loop repeats 2486 two extra times. This only happened once, unable to reproduce when I tried a few more runs.
I guess this is an error out of my control?? So what may have caused this and how is this not an issue in everyday c++ applications?
int colorful(int A) {
if(A<10) return 1;
// do something
return 0;
}
int main(void) {
//my testcases
vector<int> A = {
0,
1,
5,
236,
121,
2468,
2486,
3486,
3846,
3795
};
for(int i=0; i<A.size(); i++){
//print testcase and result.
cout << A[i] << ": " << colorful(A[i]) << endl;
}
return 0;
}r/gcc • u/[deleted] • Apr 29 '22
Does compiling C code with "gcc -Wall -g -lncurses" do this?
What if I always use return; at the end of my void functions in C? Does the compiler always place asm("ret"); asm("ret"); at the end of them? One that asm("ret") that I specified and one it does automatically?
example:
void function(){
...do some stuff...
return;
}r/gcc • u/novemberizing • Apr 06 '21
In gcc 9.3 and AVX supported environments, when optimize option is enabled, strlen function calls are up to 3x slower.
Rather, the strlen function without an optimization optiin is 3 times faster. "strlen avx" is called only when no optimized.
tested source: https://github.com/novemberizing/eva/blob/main/src/example/string/strlen.c
r/gcc • u/novemberizing • Apr 22 '21
Help me. Can you find a case where the operation below becomes 1?
Help me. I'm writing a simple code to learn AVX(Advanced Vector Extension). Can you find a case where the operation below becomes 1? It's easy, but I don't know if I can't find it or if there is no case to be 1.
tmp[255:0] := a[255:0] AND b[255:0]
IF (tmp[63] == 0 && tmp[127] == 0 && tmp[191] == 0 && tmp[255] == 0)
ZF := 1
ELSE
ZF := 0
FI
tmp[255:0] := (NOT a[255:0]) AND b[255:0]
IF (tmp[63] == 0 && tmp[127] == 0 && tmp[191] == 0 && tmp[255] == 0)
CF := 1
ELSE
CF := 0
FI
IF (ZF == 0 && CF == 0)
dst := 1
ELSE
dst := 0
FIsimple test code Intel intrinsic guide - _mm_testnzc_pd
$ gcc -mavx2 _mm256_testnzc_pd.c
$ ./a.outr/gcc • u/jph1022 • Apr 05 '22
GCC C++ - collect2.exe: error: ld returned 1 exit status
I am compiling a test .cpp code which exists in multiple files. The compiler throws a linker error and I am unable to figure out what may be the issue. The code is clean. Below is a snapshot of the g++ -v output. Any help would be appreciated.
C:\Users\user1>C:\Users\user1\Documents\software\C++compilers\GCC\mingw64\bin\g++.exe --std=c++23 -fdiagnostics-color=always -v C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\main.cpp -o C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\main.exe Using built-in specs. COLLECT_GCC=C:\Users\user1\Documents\software\C++compilers\GCC\mingw64\bin\g++.exe COLLECT_LTO_WRAPPER=c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.2.0/lto-wrapper.exe OFFLOAD_TARGET_NAMES=nvptx-none Target: x86_64-w64-mingw32 Configured with: ../configure --prefix=/R/winlibs64ucrt_stage/inst_gcc-11.2.0/share/gcc --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-offload-targets=nvptx-none --with-pkgversion='MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders' --with-tune=generic --enable-checking=release --enable-threads=posix --disable-sjlj-exceptions --disable-libunwind-exceptions --disable-serial-configure --disable-bootstrap --enable-host-shared --enable-plugin --disable-default-ssp --disable-rpath --enable-libstdcxx-pch --enable-libstdcxx-time=yes --disable-libstdcxx-debug --disable-version-specific-runtime-libs --with-stabs --disable-symvers --enable-languages=c,c++,fortran,lto,objc,obj-c++,jit --disable-gold --disable-nls --disable-stage1-checking --disable-win32-registry --disable-multilib --enable-ld --enable-libquadmath --enable-libada --enable-libssp --enable-libstdcxx --enable-lto --enable-fully-dynamic-string --enable-libgomp --enable-graphite --enable-mingw-wildcard --with-mpc=/d/Prog/winlibs64ucrt_stage/custombuilt --with-mpfr=/d/Prog/winlibs64ucrt_stage/custombuilt --with-gmp=/d/Prog/winlibs64ucrt_stage/custombuilt --with-isl=/d/Prog/winlibs64ucrt_stage/custombuilt --enable-install-libiberty --enable-__cxa_atexit --without-included-gettext --with-diagnostics-color=auto --enable-clocale=generic --with-libiconv --with-system-zlib --with-build-sysroot=/R/winlibs64ucrt_stage/gcc-11.2.0/build_mingw/mingw-w64 CFLAGS=-I/d/Prog/winlibs64ucrt_stage/custombuilt/include/libdl-win32 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders) COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-std=c++23' '-v' '-o' 'C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\main.exe' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\' c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.2.0/cc1plus.exe -quiet -v -iprefix c:\users\user1\documents\software\c++compilers\gcc\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.2.0/ -D_REENTRANT C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\main.cpp -quiet -dumpdir C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\ -dumpbase main.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -std=c++23 -version -fdiagnostics-color=always -o C:\Users\user1\AppData\Local\Temp\cciHsDk2.s GNU C++23 (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders) version 11.2.0 (x86_64-w64-mingw32) compiled by GNU C version 11.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version UNKNOWN-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring duplicate directory "c:/users/user1/documents/software/c++compilers/gcc/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include/c++/11.2.0" ignoring duplicate directory "c:/users/user1/documents/software/c++compilers/gcc/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include/c++/11.2.0/x86_64-w64-mingw32" ignoring duplicate directory "c:/users/user1/documents/software/c++compilers/gcc/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include/c++/11.2.0/backward" ignoring duplicate directory "c:/users/user1/documents/software/c++compilers/gcc/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.2.0/include" ignoring nonexistent directory "R:/winlibs64ucrt_stage/inst_gcc-11.2.0/share/gcc/include" ignoring nonexistent directory "/R/winlibs64ucrt_stage/inst_gcc-11.2.0/share/gcc/include" ignoring duplicate directory "c:/users/user1/documents/software/c++compilers/gcc/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed" ignoring duplicate directory "c:/users/user1/documents/software/c++compilers/gcc/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/include" ignoring nonexistent directory "/mingw/include" #include "..." search starts here: #include <...> search starts here: c:\users\user1\documents\software\c++compilers\gcc\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include/c++/11.2.0 c:\users\user1\documents\software\c++compilers\gcc\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include/c++/11.2.0/x86_64-w64-mingw32 c:\users\user1\documents\software\c++compilers\gcc\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include/c++/11.2.0/backward c:\users\user1\documents\software\c++compilers\gcc\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.2.0/include c:\users\user1\documents\software\c++compilers\gcc\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include c:\users\user1\documents\software\c++compilers\gcc\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed c:\users\user1\documents\software\c++compilers\gcc\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/include End of search list. GNU C++23 (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders) version 11.2.0 (x86_64-w64-mingw32) compiled by GNU C version 11.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version UNKNOWN-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: d72a0f02d610bd34c501f9b638fe12fa COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-std=c++23' '-v' '-o' 'C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\main.exe' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\' c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/as.exe -v -o C:\Users\user1\AppData\Local\Temp\cc73IXem.o C:\Users\user1\AppData\Local\Temp\cciHsDk2.s GNU assembler version 2.38 (x86_64-w64-mingw32) using BFD version (Binutils for MinGW-W64 x86_64, built by Brecht Sanders) 2.38 COMPILER_PATH=c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.2.0/;c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../libexec/gcc/;c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ LIBRARY_PATH=c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/;c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/;c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../lib/;c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/;c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../ COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-std=c++23' '-v' '-o' 'C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\main.exe' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\main.' c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.2.0/collect2.exe -plugin c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.2.0/liblto_plugin.dll -plugin-opt=c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\user1\AppData\Local\Temp\ccKEBolK.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -m i386pep -Bdynamic -o C:\Users\user1\Documents\Projects\C++\C++20_user1_tests\test_code\main.exe c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/crtbegin.o -Lc:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0 -Lc:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc -Lc:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib -Lc:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../lib -Lc:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib -Lc:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../.. C:\Users\user1\AppData\Local\Temp\cc73IXem.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lkernel32 c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/crtend.o c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user1\AppData\Local\Temp\cc73IXem.o:main.cpp:(.text+0x18): undefined reference to `max(int, int)' c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user1\AppData\Local\Temp\cc73IXem.o:main.cpp:(.text+0x62): undefined reference to `min(int, int)' c:/users/user1/documents/software/c++compilers/gcc/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user1\AppData\Local\Temp\cc73IXem.o:main.cpp:(.text+0xb8): undefined reference to `incr_mult(int, int)' collect2.exe: error: ld returned 1 exit statusIs it possible to optimise gcc itself to compile faster?
Hi,
I'm just a gentoo noob user looking for an advice. Is it possible to optimise gcc itself and reduce compilation times? What flags would you recommend?
I'm not sure if relevant but I abused my wallet and ordered 3950x + 32RAM. Any specific flags for that cpu?
I generally like just basic -O2 -march=native but I think this single package is worth tinkering.
Many thanks :)