LD_LIBRARY_PATH vs LIBRARY_PATH

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

Undefined reference to static class member

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

Missing include “bits/c++config.h” when cross compiling 64 bit program on 32 bit in Ubuntu

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

Disable all gcc warnings

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

g++ undefined reference to typeinfo

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

gcc warning” ‘will be initialized after’

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