Make dynamic link .so file from many C sources

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

merely of a single .c file ?
Last edited on
Either
gcc -o foo.so -shared -fPIC foo.c bar.c baz.c quux.c ...
or
1
2
3
4
5
6
gcc -c foo.c -o foo.o
gcc -c bar.c -o bar.o
gcc -c baz.c -o baz.o
gcc -c quux.c -o quux.o
...
gcc -o foo.so -shared -fPIC foo.o bar.o baz.o quux.o ...

If I'm not mistaken. if you're linking C and C++ sources into the same binary you have to use the latter.
Last edited on
Topic archived. No new replies allowed.