Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 04-07-2021, 10:52 PM   #1
Registered: Feb 2008
Posts: 499
Blog Entries: 1

Rep: Reputation: 38
ar -rsv some.a new.o works, what is the equivalent for gcc -shared new.o

ar -rsv some.a new.o

adds new.o into the existing some.a


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

Is something like
gcc -shared -add_to_existing new.o ?
Old 04-07-2021, 11:03 PM   #2
Registered: Feb 2008
Posts: 499

Original Poster
Blog Entries: 1

Rep: Reputation: 38

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.

Last edited by centguy; 04-07-2021 at 11:21 PM.
Old 04-11-2021, 09:28 AM   #3
Registered: Feb 2008
Posts: 499

Original Poster
Blog Entries: 1

Rep: Reputation: 38
I have two solutions:

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

gcc -shared -o a.o

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

2. generate a full from all .o

gcc -shared -o / /*.o

Then use gcc main.c -L/ -lall

Not sure this is the standard way but it works.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with GCC: while loading shared libraries: cannot open shared object file: No such file or directory juju Slackware 17 05-21-2020 06:34 PM
Rosewill RSV-S8 external enclosure. Any experience? Nutria Linux - Hardware 10 06-06-2013 05:43 PM
[SOLVED] SEGMENTATION FAULT using gcc 4.4.4 -O2 , works with gcc 4.1.0 -O2 or gcc 4.4.4 -O1 amir1981 Programming 36 07-26-2010 06:07 PM
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
equivalent of conio.h in gcc? (and some more gcc-newbie questions) Valkyrie_of_valhalla Programming 3 09-22-2007 03:32 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration