Problem with linking with --whole-program

Henrik Mannerström henrik.mannerstrom@gmail.com
Fri Dec 14 10:11:00 GMT 2012


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() {
}



More information about the Gcc-help mailing list