Problem with linking with --whole-program
Henrik Mannerström
henrik.mannerstrom@gmail.com
Fri Dec 14 11:14:00 GMT 2012
Ok, thank you! I had misunderstood the whole-program option. I think the
-flto was added in gcc 4.5 so I will just have to go without it.
- Henrik
On 12/14/2012 12:30 PM, Florian Weimer wrote:
> 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.
>
More information about the Gcc-help
mailing list