简体   繁体   中英

Shared library from C and C++ object files

Can I create a shared library from the C and C++ object files?. If possible where should I use it? (in C/C++ applications or both).

You can create shared library from .o file (Create from C or C++ file) and use it into C or C++ application.

There is here and here tutorials about shared library that show how compile shared library and how use it.

If you have any question about it, you are welcome.

Not all situation you can do that. If you have source code, you can compile them as:

gcc -fPIC exam.c -o exam.o
gcc -shared exam.o -o libexam.so

PIC means position-independent code. And if a object file is compiled with -fPIC, it can be used to create shared lib.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM