Questions tagged [g++]

1

votes
1

answer
239

Views

g++ turn off constant propagation for benchmarking?

I want to run a simple benchmark of a function in C++ with a few function calls that use hard coded inputs. inline Output simple_func_to_test(const Input input); int main(int argc, char* argv[]) { // The value of input is known at compile time. const Input input; // The value of output can be deduce...
Praxeolitic
1

votes
1

answer
44

Views

OpenGL C++ with g++ compiler, not able to find GLFW on Windows 10 (no Visual Studio)

I'm trying to setup an OpenGL API from Scratch using C++ with g++ compiler. Currently I'm trying to get a simple windowing system using GLFW but when I compile the program it doesn't seem to find the GFLW directory. I'm trying to do this from the very scratch, so I'm not going to use any IDE like Vi...
Miger
1

votes
2

answer
55

Views

Why STD::SIZE() is not a member of STD in GCC 8.2.0

I'm trying to teach myself some c++17. Why is that compiler throws an error for the below code snippet? #include #include #include int main() { std::vector v = { 3, 1, 4 }; std::cout
thumala manish
1

votes
1

answer
47

Views

Is there a way to disable inline assembler in GCC?

I'm developing an online judge system for programming contests like LeetCode, Codeforces, etc. As for most programming contests, inline assembler is not allowed in C/C++, so I would like to add the same restriction to my system. I would like to let GCC and G++ produce an error when compiling a C/C+...
Wang Tianze
2

votes
0

answer
29

Views

How to force gRPC cpp program using single thread only

I need to run my client application (written in c++ with gRPC) in an operating system (which only support single thread). However, I noticed that grpc::InsecureChannelCredentials(); is trying to create multiple threads. Here is the output from debugger after calling that gRPC function in my host mac...
J.Z
1

votes
2

answer
64

Views

Is it legitimate to assign values to non-array objects with braces?

I discovered by accident that this works in the body of a program:(currently using g++ 5.2.0) Vector4 pos; pos = {0.0, 1.1, 2.2, 3.3}; The Vector4 class declares this data as named variables: double t, x, y, z; not as an array, and has no auto conversion cnstrs. I guess memory storage...
G.Ramian
1

votes
2

answer
113

Views

Speeding up gcc compile of a single file

Running RedHat7 w/g++ version 4.8.3 w/j5 arg and o3 optimization. We currently have a file that is approx 90,000 lines long (a whole bunch of wrapper functions). The compile of this file currently takes between 30 and 40 mins. What is the best strategy to speed this build time? Would build time incr...
static_cast
1

votes
1

answer
1.3k

Views

include GLEW, glfw3 and glm using g++ mac [closed]

Half a year ago, i was using the libraries glfw3, GLEW and glm to make c++ projects with openGL graphics, and it did work very well, but now i can no longer include these libraries. When things were working fine, i was able to include the three libraries in my c++ files like this: #include #inclu...
Nikolaj
1

votes
1

answer
431

Views

How to link objects in different directories in c++ with make without refering to them in the makefile?

I'm trying to clean up my project a little and I want to put object files and include files in a separate folder and be able to compile another makefile in my a different testing subdirectory. I would like to do this so that the make file in the testing directory doesn't have to know about the obje...
Shane P Kelly
1

votes
2

answer
123

Views

G++ floating point precision

I have these lines in a C++ program, auto f = log (FLT_MAX / 4); printf('%e', f); cout
Albertus
1

votes
1

answer
1k

Views

Undefined reference yyparse c++

I am developing a simple interpreter using bison and flex. When I compile my code I am getting the error of 'undefined reference to 'yyparse'. mylang.ll %{ /******************** C-libraries and Token definitions *****************/ #include /* for strdup */ #include 'mylang.yy.tab....
Smith Dwayne
1

votes
1

answer
364

Views

Error when compiling cpp file with g++

I have a CentOS 7 install running GCC 4.8.5 and I can successfully compile a cpp file named MyClass. I use the following command to compile the file: g++ -c -fpermissive $(pkg-config --cflags --libs libavformat libavcodec libswscale libavutil) ./MyClass.cpp When I run this command on a Centos 6.7 r...
kernelK
1

votes
1

answer
384

Views

g++ ultra verbosity nightmare

This is for a single error. I had to cut it down in order to post it here. How to disable this madness ? (g++ 5.3.1) [email protected]:~/projectClient# ./build project/update.cpp: In function ‘bool is_recentlyProcessed(IntervalTime, ulong)’: project/update.cpp:71:80: error: no match for ‘operator...
lxndr
1

votes
1

answer
52

Views

Compiling with c++ and getting “ready to go” executable

Is it possible to compile a program with g++ so that shared libraries etc are 'included' with the executable? I have a c++ program that I'd like to compile and run at another location where I'm missing some libraries and don't have install access. The main reason I couldn't find answers for this is...
jorgen
1

votes
2

answer
48

Views

include processed prepocessor directives into `g++ -E' output

I'm having some preprocessing mishap while compiling a 3rd party library with g++. I can see in -E output that a certain header wrapped with #ifndef SYMBOL is being bypassed. Apparently, that symbol has been defined somewhere else. But I cannot see where because processed directives are not present...
ivan_pozdeev
1

votes
2

answer
99

Views

Compiler behavior with const static non integral data initialization, namespace vs struct

Let say that I have two different versions of the same header foo.hpp, the first one: // File foo.hpp #ifndef FILE_FOO #define FILE_FOO namespace X { static const int i = 13; static const double d = 17.0; } #endif and the second one: // File foo.hpp #ifndef FILE_FOO #define FILE_FOO struct X { st...
helmet_23
1

votes
1

answer
265

Views

GMP Library - File I/O

Okay. So I'm using GMP library to calculate big numbers. I've got code like this: #include #include #include #include #include using std::cout; using std::endl; int main(int argc, char** argv) { FILE *file; file = fopen('data.txt', 'wt'); int number=atoi(argv[1]), i=1; mpz_t a; mpz_init(a); mpz...
1

votes
2

answer
316

Views

Missing shared libraries (g++ compile)

Okay. So I've got simple app using GMP library. Here's the code: #include #include using std::cout; using std::endl; int main(int argc, char** argv) { int number=100; mpz_t a; mpz_init(a); mpz_t b; mpz_init(b); mpz_set_ui(b, 1); cout
1

votes
1

answer
3.7k

Views

FFmpeg Ubuntu linker error

I am trying to decode audio using ffmpeg lib and c++ from Ubuntu 12.04. I am following the code here https://0xdeafc0de.wordpress.com/2013/12/19/ffmpeg-audio-playback-sample/ Below is the command used to compile the code g++ -std=c++11 decode_play_audio.cpp -I/home/codeDev/ffmpeg_sources/build_Mar-...
CodeDezk
10

votes
1

answer
287

Views

c++ “#include” output explanation

Trying to understand how #include works. I'm reading that, during pre-procesing, it just replaces itself with the contents of the referenced file. To verify, I create two files. A file named otherfile containing only the string 1234, and a file test.cpp which contains #include otherfile abcd I run...
blue_note
2

votes
0

answer
23

Views

SFINAE: Detecting existence of member variable does not work on g++

I'm trying to combine the approaches used in this answer for detecting whether a class has a member variable x with this answer to select different implementations depending on that using enable_if. Basically, I want to write a trait class that, given a type T, provides access to the member T::x if...
Andre
1

votes
1

answer
124

Views

Build C application by C++ compiler

I have an application, which is written on C. A new functionality I need to add in C++. I build C application with GCC. To add new functionality: To build an existing application with G++. Add new functionality. When I tried to do (1.), I met following problem: In file dev_table.c defined array: co...
1

votes
1

answer
115

Views

Did the lifetime of c_str() changed between g++ 4.8.4 and g++ 5.3.1?

I start processes from a daemon which makes sure that said processes run continuously and get started in the proper order, etc. At some point, I want to start the process with execv() so I prepare an array of string for the arguments as so: std::vector args; args.push_back('--debug'); args.push_back...
Alexis Wilke
1

votes
1

answer
472

Views

Linking Leap Motion SDK with Cmake

Im trying to build a project which uses the Myo SDK and the LeapMotion SDK on Windows 7 with CMake, Qt Creator and MinGW 4.9.2 32bit as compiler. The MyoSDK ist working fine but I have some problems with linking the LeapMotion SDK in CMake. I found an existing sample CMake file which says that the W...
Nico R.
1

votes
1

answer
438

Views

g++ not find .so files

I am trying to generate a c++ library using the g++ compiler. My library has another C library as dependency and I have compiled it in order to obtain the .so files. I have the following structure: src: include/linux: libcustom.a libcustom.la libcustom.so libcustom.so.0 libcustom.so.0.0.0 Now, when...
bra_racing
1

votes
2

answer
1.7k

Views

Error in nested template argument when compile c++ in unix

I just wrote a cpp file in unix. I have bunches of codes that use nested template argument. For example: void showAlb(map mapArt, map mapSong, vector artists, int artnumb); However I always got error ` error: ?>?should be ? >?within a nested template argument list ` void showAlb(map mapArt, map map...
RunningPig
1

votes
1

answer
95

Views

What is std::__scan_keyword?

I'm looking for simply library for human likely std::chrono input/output. And I've found one - chrono_io. Output works fine. But input don't work. I got compile time error error: ‘__scan_keyword’ was not declared in this scope. What is __scan_keyword? #include #include #include #include 'chro...
sba
1

votes
1

answer
147

Views

C++ class methods do not have an address range in DWARF info

I'm trying to parse the DWARF debug info to determine the functions from a stack trace address. If it works for my C functions (compiled with gcc), it doesn't for my C++ functions (compiled with g++) My C functions all have a in the .debug_info table a DW_AT_low_pc and a DW_AT_low_high attribute whi...
user7094
1

votes
1

answer
276

Views

Where is __v2di declared when using -std=c++11 under GCC?

I'm having trouble compiling some code under GCC 4.9 when using -std=c++11. GCC 4.9 is provided under Debian 8.5 (Stable), so its fairly popular. The relevant code is: __inline __m128i clmulepi64_si128 (__m128i a, __m128i b, const int i) { asm ('pclmulqdq %2, %1, %0' : '+x'(a) : 'xm'(b), 'i'(i)); re...
jww
1

votes
1

answer
101

Views

temporary objects with variadic template arguments; another g++/clang++ difference

The following code struct foo { foo () { } template foo (const T0 & t0, const Ts & ... ts) { foo(ts...); } }; int main() { foo f(1, 2); return 0; } compile without problems with g++ (4.9.2) and give the following errors tmp_002-11,14,gcc,clang.cpp:9:16: error: expected ')' { foo(ts...); } ^ tmp_00...
max66
1

votes
1

answer
468

Views

Link to ffmpeg libraries using mingw c++ -> undefined reference [duplicate]

This question already has an answer here: Libav linking error: undefined references 3 answers I read about a lot of very similar problems here, but none of them seems to solve my problem. I feel that I need only a very small step to succeed... I have an existing c++ project and try to include some...
Gerhard
1

votes
1

answer
471

Views

c++ freopen 2 files error

I get and error while doing 2 sequential freopens , file1 contains even number of ints int x, y; freopen('file1', 'r', stdin); while (cin >> x) { cin >> y; } freopen('file2', 'r', stdin); cin >> x; cout
Herokiller
1

votes
1

answer
82

Views

Explicit destructor call is not working

Simplified version of my c++ Class: class Class { public: Class(uint32_t size_, uint8_t val_) buf(NULL), size(size_) { buf = new uint8_t[size]; memset(buf, val_, size); } ~Class() { if(buf != NULL) { delete[] buf; buf = NULL; size = 0; } } void FakeDtor() { if(buf != NULL) { delete[] buf; buf = NULL...
Klepak
1

votes
1

answer
388

Views

IRQ 6 floppy disk controller interrupt not triggered

For some reason, IRQ 6 never hits in my Qemu, Bochs, VMWare, or VirtualBox emulators. Do I need some type of virtual Floppy Drive or something? Here is my IRq6 handler: void i86_flpy_irq (struct regs *r) { //! irq fired _FloppyDiskIRQ = 1; printf('IRQ 6 HIT'); } It never says 'IRQ 6 HIT', and not...
amanuel2
1

votes
1

answer
73

Views

code does not compile in g++ while it does in clang++

So I have this really short code: test.cpp class Base { public: Base(int i) {}; }; class Child : public virtual Base { using Base::Base; }; int main(int argc, char * argv[]) { auto *child = new Child(1); return 0; }; It compiles well under clang++ (3.8.0): $ clang++ test.cpp -std=c++11 while it fail...
freakish
1

votes
1

answer
415

Views

Unknown missing libraries; -lGraf3d, -lPostscript and -lPhysics

Warning: Newbie Ubuntu/g++ user I'm trying to build a C++ app (C++11, OpenMP, OpenCV3, experimental filesystem) that works on another platform, but I get linker errors for missing libraries. The names are too generic to find answers via Google. What do I need to install and/or configure to resolve t...
cdmh
1

votes
2

answer
476

Views

g++ fails to link .o files into an executable

I am doing an example drill in the textbook I am using to learn from. All I need to do is compile, link and run the following 3 files: //file my.h extern int foo; void print_foo(); void print(int); my.h is a simple header file that declares the two functions and a 'global' int foo, with no initial v...
gasoline
1

votes
1

answer
478

Views

Correct Template constructor for MBED Callback of member function

I am using the mbed library and want to attach a member function to a Ticker (calls a callback function on regular interval) which is also a member. I may have multiples instances of my class and I would like each one to be able to manage its own Ticker and to allow the callback function to deal wi...
ptpaterson
1

votes
3

answer
72

Views

Compiling simpleChat.C from Wt Example Error

I made changes in simpleChat.C file removing 'I'm schizophrenic ...' Button. of simplechat example from wt in Ubuntu. And tried compiling it with command: sudo g++ -o simplechat simpleChat.C -lwthttp -lwt Error: /usr/bin/ld: /tmp/ccHOujNG.o: undefined reference to symbol '_ZN5boost6system15system_c...
Anjali
1

votes
1

answer
864

Views

Cannot compile a C++ program using AVX512?

I got an error below when a program (test.cpp) is compiled: > g++ -o test test.cpp -O2 -mavx -msse4.1 test.cpp: In function ‘int main(int, char**)’: test.cpp:18:42: error: ‘_mm_rorv_epi32’ was not declared in this scope indice = _mm_rorv_epi32(indice, offset4); ^ The program (main.cpp): #inc...
zhanxw

View additional questions