Andes Workshop http://forum.andestech.com/ |
|
How to force gcc to link an unused static library http://forum.andestech.com/viewtopic.php?f=25&t=875 |
Page 1 of 1 |
Author: | cindy [ Sun Aug 03, 2014 12:28 am ] |
Post subject: | How to force gcc to link an unused static library |
Option: Code: Use --whole-archive linker option. Libraries that come after it in the command line will not have unreferenced symbols discarded. You can resume normal linking behaviour by adding --no-whole-archive after these libraries. In your example, the command will be: g++ -o program main.o -Wl,--whole-archive /path/to/libmylib.a In general, it will be: g++ -o program main.o \ -Wl,--whole-archive -lmylib \ -Wl,--no-whole-archive -llib1 -llib2 Reference: http://stackoverflow.com/questions/1411 ... ic-library Sample code Attachment: Attachment: Attachment: The link option of usercode4 nds32le-elf-gcc -O0 -static -L../ -Wl,--whole-archive -llibcount -Wl,--no-whole-archive -T"nds32.ld" -o "usercode4.adx" ./main.o |
Page 1 of 1 | All times are UTC + 8 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |