Compiling with g++ using multiple cores
Quick question: what is the compiler flag to allow g++ to spawn multiple instances of itself in order to compile large projects quicker (for example 4 source files at a time for a multi-core CPU)? 8 Answers 8
Quick question: what is the compiler flag to allow g++ to spawn multiple instances of itself in order to compile large projects quicker (for example 4 source files at a time for a multi-core CPU)? 8 Answers 8
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 with: /usr/bin/ld: cannot find -lyaml-cpp I expected that to work because according to the ld man … Read more
I’m compiling my C++ app using GCC 4.3. Instead of manually selecting the optimization flags I’m using -march=native, which in theory should add all optimization flags applicable to the hardware I’m compiling on. But how can I check which flags is it actually using? 5 Answers 5
How do I install g++ for Fedora Linux? I have been searching the dnf command to install g++ but didn’t find anything. How do I install it? I have already installed gcc 10 Answers 10
Can anyone explain why following code won’t compile? At least on g++ 4.2.4. And more interesting, why it will compile when I cast MEMBER to int? #include <vector> class Foo { public: static const int MEMBER = 1; }; int main(){ vector<int> v; v.push_back( Foo::MEMBER ); // undefined reference to `Foo::MEMBER’ v.push_back( (int) Foo::MEMBER ); … Read more
I am running the 32bit version of Ubuntu 10.10 and trying to cross compile to a 64 bit target. Based on my research, I have installed the g++-multilib package. The program is a very simple hello world: #include <iostream> int main( int argc, char** argv ) { std::cout << “hello world” << std::endl; return 0; … Read more
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 that generate warnings, which are of no interest to me. How do I disable all … Read more
I want to write a macro in C that accepts any number of parameters, not a specific number example: #define macro( X ) something_complicated( whatever( X ) ) where X is any number of parameters I need this because whatever is overloaded and can be called with 2 or 4 parameters. I tried defining the … Read more
I just ran across the following error (and found the solution online, but it’s not present in Stack Overflow): (.gnu.linkonce.[stuff]): undefined reference to [method] [object file]:(.gnu.linkonce.[stuff]): undefined reference to `typeinfo for [classname]’ Why might one get one of these “undefined reference to typeinfo” linker errors? (Bonus points if you can explain what’s going on behind … Read more
I am getting a lot of these warnings from 3rd party code that I cannot modify. Is there a way to disable this warning or at least disable it for certain areas (like #pragma push/pop in VC++)? Example: list.h:1122: warning: `list<LogOutput*, allocator<LogOutput*> >::node_alloc_’ will be initialized after list.h:1117: warning: `allocator<LogOutput*> list<LogOutput*, allocator<LogOutput*> >::alloc_’ 7 Answers … Read more