How do I create a shared library in Linux?

Phương Linh

New member
How do I create a shared library in Linux?
Answer
Example with code:
  1. Compile the library functions: gcc -Wall -fPIC -c ctest1.c ctest2.c.
  2. Generate the shared library: gcc -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0 ctest1.o ctest2.o. …
  3. Move to lib/ directory: …
  4. Configure the library path (see below and choose one of three mechanisms). …
  5. Run the program: ./prog Valx=5.
 

Tìm kiếm

Back
Top