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-librarySample code
Attachment:
usercode3_4.zip [117.38 KiB]
Downloaded 659 times
Attachment:
u3.png [ 59.3 KiB | Viewed 6728 times ]
Attachment:
u4.png [ 66.16 KiB | Viewed 6728 times ]
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