Are you using GCC 4.9.0?

Since GCC 4.9.0, LTO-enabled object file doesn't contain normal object code
but GIMPLE bytecode by default.
If you want to link to a static library, you have to pass
-fuse-linker-plugin to let it extract LTO segments, and AFAIK it's enabled
by default when -flto is passed.
But I don't know why, the linker plugin of MinGW seems not working, it
always tell me some symbols are undefined.
So instead, you may pass -ffat-lto-objects to make it generate object files
with normal object code, but you won't benefit from LTO.



2014-04-26 18:39 GMT+08:00 lh_mouse <[email protected]>:

> Hello there, do I need -flto when building a static lib?
> Here is an example:
>
> E:\Desktop>gcc foo.c -c -flto
> E:\Desktop>ar rcs libfoo.a foo.o
> E:\Desktop>gcc main.c -L. -lfoo -flto
> C:\Users\LH_Mouse\AppData\Local\Temp\ccc30oDd.ltrans0.ltrans.o:ccc30oDd.ltrans0.o:(.text+0x1e):
> undefined reference to `foo'
> collect2.exe: error: ld returned 1 exit status
>
> Without those -flto options these commands worked just well.
> Looking forward to you reply.
>
> --------------
> Best regards,
> lh_mouse
> 2014-04-26
>
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to