LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   ar -rsv some.a new.o works, what is the equivalent for gcc -shared some.so new.o (https://www.linuxquestions.org/questions/linux-software-2/ar-rsv-some-a-new-o-works-what-is-the-equivalent-for-gcc-shared-some-so-new-o-4175693309/)

centguy 04-07-2021 10:52 PM

ar -rsv some.a new.o works, what is the equivalent for gcc -shared some.so new.o
 
ar -rsv some.a new.o

adds new.o into the existing some.a

However

gcc -shared some.so new.o
seems to "add" the new.o into the shared object some.so while removing the old stuff.

Is something like
gcc -shared -add_to_existing some.so new.o ?

centguy 04-07-2021 11:03 PM

https://www.cprogramming.com/tutoria...linux-gcc.html

tells how to generate a new shared object based on one NEW src file. But if we have multiple src files then this method won't work.

i wish to keep adding new entries in .so just like using ar.

centguy 04-11-2021 09:28 AM

I have two solutions:

1. convert a.o to liba.so every time we create a.o via

gcc -shared -o liba.so a.o

to link use gcc -shared -L/pathto.so/ -la -lb etc main.c

2. generate a full liball.so from all .o

gcc -shared -o /pathto.so/liball.so /pathto.so/*.o

Then use gcc main.c -L/pathto.so/ -lall


Not sure this is the standard way but it works.


All times are GMT -5. The time now is 01:39 AM.