Problem with linking with --whole-program

Florian Weimer fweimer@redhat.com
Fri Dec 14 10:30:00 GMT 2012


On 12/14/2012 11:11 AM, Henrik Mannerström wrote:
> 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?

--whole-program itself does not cause the compiler to combine 
translation units.  Both input files are compiled separately and flat 
out violate the assumptions of --whole-program.

Try passing -flto as well.

-- 
Florian Weimer / Red Hat Product Security Team



More information about the Gcc-help mailing list