Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The making of shared Library under linux and its Common problems

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Generate a shared library from a linked list written by yourself

  1, compilation

  2. Set the library name:

The name format of the     library: lib + XXX + version number .so (library name is XXX)

-shared generates a shared file library-fpic dynamic link

  3, put the header file and .so file in the system directory

(using shared libraries, change the previous # include "list.h" to # include

< list.h >

Delete the list.* in this folder and run it successfully)

  4. Link library: gcc main.c-o main-lList

  Note: if .h is not placed under the system path, use the-I path

If .so is not placed under the system path, use the-L path

If the shared library is not placed under the system path, how to solve the problem that cannot be found at run time

  1) first, move .h and .so to a non-system path and link to generate an executable file that cannot be found at run time:

  2) solution 1: modify the shared library configuration file / etc/ld.so.conf to add the path of .so to the configuration file; execute: ldconfig

   solution 2: configure the environment variable LD_LIBRARY_PATH

(however, this method is temporary and only valid for the current user this login)

You can also view the value of the environment variable: $LD_LIBRARY_PATH

Then modify it, LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/mnt/hgfs/share/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report