public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* build/make one dynamic link .so file from many C source
@ 2020-11-12  0:16 Budi
  2020-11-12  0:29 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Budi @ 2020-11-12  0:16 UTC (permalink / raw)
  To: gcc-help

How do we build/make one dynamic link .so file from many C source TUs
(translation units) as
gcc -o foo.so -shared -fPIC foo.c

of a single .c file ?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: build/make one dynamic link .so file from many C source
  2020-11-12  0:16 build/make one dynamic link .so file from many C source Budi
@ 2020-11-12  0:29 ` Jonathan Wakely
  2020-11-12  1:28   ` Budi
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2020-11-12  0:29 UTC (permalink / raw)
  To: Budi; +Cc: gcc-help

On Thu, 12 Nov 2020 at 00:19, Budi via Gcc-help <gcc-help@gcc.gnu.org> wrote:
>
> How do we build/make one dynamic link .so file from many C source TUs
> (translation units) as
> gcc -o foo.so -shared -fPIC foo.c
>
> of a single .c file ?


gcc -o foo.so -shared -fPIC foo.c bar.c baz.c

Or compile each TU to an object file separately and link the objects:

gcc -c -fPIC foo.c
gcc -c -fPIC bar.c
gcc -c -fPIC baz.c
gcc -o foo.so -shared -fPIC foo.o bar.o baz.o

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: build/make one dynamic link .so file from many C source
  2020-11-12  0:29 ` Jonathan Wakely
@ 2020-11-12  1:28   ` Budi
  2020-11-12  9:03     ` Stefan Ring
  0 siblings, 1 reply; 4+ messages in thread
From: Budi @ 2020-11-12  1:28 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-help

just curious,
it's actually g++ executable or (from gcc command silently passed to)
ld executable task/processs ?

On 11/12/20, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On Thu, 12 Nov 2020 at 00:19, Budi via Gcc-help <gcc-help@gcc.gnu.org>
> wrote:
>>
>> How do we build/make one dynamic link .so file from many C source TUs
>> (translation units) as
>> gcc -o foo.so -shared -fPIC foo.c
>>
>> of a single .c file ?
>
>
> gcc -o foo.so -shared -fPIC foo.c bar.c baz.c
>
> Or compile each TU to an object file separately and link the objects:
>
> gcc -c -fPIC foo.c
> gcc -c -fPIC bar.c
> gcc -c -fPIC baz.c
> gcc -o foo.so -shared -fPIC foo.o bar.o baz.o
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: build/make one dynamic link .so file from many C source
  2020-11-12  1:28   ` Budi
@ 2020-11-12  9:03     ` Stefan Ring
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Ring @ 2020-11-12  9:03 UTC (permalink / raw)
  To: Budi; +Cc: gcc-help

On Thu, Nov 12, 2020 at 2:30 AM Budi via Gcc-help <gcc-help@gcc.gnu.org> wrote:
>
> just curious,
> it's actually g++ executable or (from gcc command silently passed to)
> ld executable task/processs ?

gcc/g++ invokes ld. You can see this if you pass the -v flag. Well,
actually it runs its own collect2 program, which is a wrapper around
ld.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-12  9:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12  0:16 build/make one dynamic link .so file from many C source Budi
2020-11-12  0:29 ` Jonathan Wakely
2020-11-12  1:28   ` Budi
2020-11-12  9:03     ` Stefan Ring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).