g++

GCC Cross compile to a i586 architecture (Vortex86DX)

纵然是瞬间 提交于 2020-01-28 10:21:48
问题 I have Ubuntu 12.01 with gcc 4.8.2 and would like to cross compile for the Vortex86DX CPU running an old 2.6.23 kernel. I´m trying the following testing code: #include <iostream> int main() { std::cout << "Hello world" << std::endl; } That is compiled using the following command line: g++ -static-libgcc -static-libstdc++ -march=i586 test.cpp -otest586 When I run the test586 on the target architecture I´m getting this error: $ ./test586 ./teste586: symbol lookup error: ./test586: undefined

MinGW g++: Multiple definition of vsnprintf when using to_string

自作多情 提交于 2020-01-27 12:49:19
问题 I just started using MinGW for Windows. When trying to create executable using g++ a.cpp -o a.exe -std=c++14 for the code below: #include <string> using namespace std; int main() { string x = to_string(123); return 0; } I'm getting following error: C:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libmingwex.a(vsnprintf.o):(.text+0x0): multiple definition of vsnprintf C:\Users\..\Local\Temp\cc4sJDvK.o:c:/mingw/include/stdio.h:426: first defined here collect2.exe: error: ld returned 1 exit status

C++ function name demangling: What does this name suffix mean?

北慕城南 提交于 2020-01-23 01:39:31
问题 When I disassemble the Chromium binary I notice there are functions named in this pattern: _ZN6webrtc15DecoderDatabase11DecoderInfoD2Ev.part.1 If I give this string to c++filt, the output is webrtc::DecoderDatabase::DecoderInfo::~DecoderInfo() [clone .part.1] So what does this .part.1 suffix really mean? If it indicates there are multiple copies of the same function, why do they need that? Is it due to the requirement of being position independent? I used g++ as the compiler. 回答1: It

A 'using' statement compiles with g++, fails compilation with clang

眉间皱痕 提交于 2020-01-21 06:35:47
问题 I have code of the following structure (which is of course much more complex in reality, especially "Base" is a three-liner, but I've tried to capture the gist of it): template <class T> class A {}; template <class T> class B { public: B(){}; }; template <class T> class C : public B<A<T>> { public: using Base = B<A<T>>; using Base::B; }; static const C<int> c{}; The code compiles fine with g++ via g++ -c test.cpp -std=c++11 However, with clang++ I get an error message I don't really

A 'using' statement compiles with g++, fails compilation with clang

泄露秘密 提交于 2020-01-21 06:34:06
问题 I have code of the following structure (which is of course much more complex in reality, especially "Base" is a three-liner, but I've tried to capture the gist of it): template <class T> class A {}; template <class T> class B { public: B(){}; }; template <class T> class C : public B<A<T>> { public: using Base = B<A<T>>; using Base::B; }; static const C<int> c{}; The code compiles fine with g++ via g++ -c test.cpp -std=c++11 However, with clang++ I get an error message I don't really

C++ std::ifstream in constructor problem

房东的猫 提交于 2020-01-21 05:12:38
问题 I've got a problem with this code: #include <fstream> struct A { A(std::ifstream input) { //some actions } }; int main() { std::ifstream input("somefile.xxx"); while (input.good()) { A(input); } return 0; } G++ outputs me this: $ g++ file.cpp file.cpp: In function `int main()': file.cpp:17: error: no matching function for call to `A::A()' file.cpp:4: note: candidates are: A::A(const A&) file.cpp:6: note: A::A(std::ifstream) After changing it to this it compile (but that is not solving the

Undocumented GCC Extension: VLA in struct

纵然是瞬间 提交于 2020-01-19 05:42:23
问题 While reading the Clang documentation, I came across the following intriguing tidbit: [1] clang does not support the gcc extension that allows variable-length arrays in structures. This is for a few reasons: one, it is tricky to implement, two, the extension is completely undocumented, and three, the extension appears to be rarely used. Note that clang does support flexible array members (arrays with a zero or unspecified size at the end of a structure). How can this extension be used? My

Why gcc 4.1 + gcov reports 100% branch coverage and newer (4.4, 4.6, 4.8) reports 50% for “p = new class;” line?

筅森魡賤 提交于 2020-01-19 03:28:05
问题 When gcc 4.1 (using gcov) next line: p = new Class; is reported as 100% branch coverage <-- THIS IS OK for me. Why using gcc 4.4 and higher same line is reportted as: [+ -] p = new Class; (50% branch coverage)... <-- THIS IS a problem for covering 100% !!! Can I set any extra options to newer gcc versions in order to report same branch coverage as gcc 4.1 for single lines as "p = new Class;". Thanks in advance. 回答1: Solved ! We have some C/C++ files with and without exceptions handling, so

c++ undefined reference to vtable

蹲街弑〆低调 提交于 2020-01-18 16:48:08
问题 I'm learning C++. I'm trying to do an exercise where I define several implementations of a pure virtual class with a single function. I'm having trouble linking the class that uses these implementations. ==> BasicMath.h <== #ifndef BASIC_MATH_H #define BASIC_MATH_H #include<string> #include<vector> class BasicMath { }; #endif // BASIC_MATH_H ==> Operation.h <== #ifndef OPERATION #define OPERATION #include<string> #include<vector> class Operation { public: virtual void perform(std::vector<std:

How to create a static library with g++?

冷暖自知 提交于 2020-01-18 04:46:30
问题 Can someone please tell me how to create a static library from a .cpp and a .hpp file? Do I need to create the .o and the .a? I would also like to know how can I compile a static library in and use it in other .cpp code. I have header.cpp , header.hpp . I would like to create header.a . Test the header.a in test.cpp . I am using g++ for compiling. 回答1: Create a .o file: g++ -c header.cpp add this file to a library, creating library if necessary: ar rvs header.a header.o use library: g++ main