This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Problem with linking with --whole-program
- From: Henrik Mannerström <henrik dot mannerstrom at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 14 Dec 2012 12:11:08 +0200
- Subject: Problem with linking with --whole-program
Hello,
My program won't link when I add the '--whole-program' option with gcc
4.4.6. It compiles fine with 'g++ -o prog prog.cc test1.cc', but reports
prog.cc:3: undefined reference to `A::A()'
prog.cc:3: undefined reference to `A::~A()'
with 'g++ --whole-program -g -o prog prog.cc test1.cc'
Is this a c++ issue or something with gcc?
BR,
Henrik Mannerström
test1.h:
#ifndef test1_h
#define test1_h
class A {
public:
A();
~A();
};
extern A a;
#endif /* test1_h */
test1.cc:
#include "test1.h"
A::A() {}
A::~A() {}
prog.cc:
#include "test1.h"
A a;
int main() {
}