このページは大阪弁化フィルタによって翻訳生成されたんですわ。

翻訳前ページへ


>
1. Bevezet駸
1.1. Magyar ford?疽
2. Statikus programk?yvt疵ak
3. Megosztott programk?yvt疵ak
3.1. Konvenci?
3.2. Hogyan haszn疝juk a programk?yvt疵akat?
3.3. K?nyezeti v疝toz?
3.4. Megosztott programk?yvt疵ak k駸z?駸e
3.5. Megosztott programk?yvt疵ak telep?駸e 駸 haszn疝ata
3.6. Inkompatibilis programk?yvt疵ak
4. dlclose()
4.5. DL programk?yvt疵 p駘da
5. Egy饕
5.1. nm utas?疽
5.2. libhello.c f疔l
6.2. libhello.h f疔l
6.3. demo_use.c f疔l
6.4. script_static f疔l
6.5. script_shared f疔l
Ez a le?疽 el?z? a statikus programk?yvt疵akkal foglalkozik, melyeket a program futtat疽a el?t kell az alkalmaz疽hoz szerkeszteni. Ezt k?et?n foglalkozik a megosztott (shared) programk?yvt疵akkal, amelyek a program indul疽akor >

2. Statikus programk?yvt疵ak

A statikus programk?yvt疵ak k??s馮es t疵gyk?-f疔lok gy?tem駭yei. t疵gyk?-f疔lokat a my_library.a statikus programk?yvt疵hoz. L騁rehozza a my_library.a f疔lt, ha az nem l騁ezett. Tov畸bi inform當i?at a statikus programk?yvt疵ak k駸z?駸駻? az ar(1)-ben tal疝sz.

3. Megosztott programk?yvt疵ak

Megosztott programk?yvt疵ak olyan programk?yvt疵ak, amiket a program indul疽akor t?t be. Ha a megosztott programk?yvt疵ak megfelel?n vannak telep?ve, az ?szes program az indul疽a ut疣 automatikusan ? megosztott programk?yvt疵at haszn疝. Ez enn駘 egy kicsit rugalmasabb 駸 bonyolultabb jelenleg, mert a linuxos megold疽 megengedi azt is, hogy:


5. Egy饕


5.5. GNU libtool

Ha olyan alkalmaz疽t k駸z?esz amit t?b rendszerre szeretn駘 haszn疝ni, akkor javasolt a GNU libtool

/* Explain here what foobar does */

#ifndef FOOBAR_H
#define FOOBAR_H

#ifdef __cplusplus
extern "C" {
#endif

 ... header code for foobar goes here ...

#ifdef  __cplusplus
}
#endif
#endif

5.10. Linux Standard Base (LSB)

A Linux Standard Base (LSB) projekt c駘ja, hogy olyan szabv疣yokat dolgozzon ki HREF="http://www.yansite.jp/osaka2.cgi?URL=http://www-106.ibm.com/developerworks/linux/library/l-lsb.html?t=gr,lnxw02=LSBapps" TARGET="_top" >Developing LSB-certified applications: Five steps to binary-compatible Linux applications. Term駸zetesen a k?ot ?y kell meg?ni, hogy egy standardiz疝t r騁eget >

 $ lsbappchk myapplication
Az LSB csomagol疽i ?mutat? is k?etned kell (pl. haszn疝j RPM v3-at, haszn疝j LSB 疝tal meghat疵ozott csomagneveket, 駸 az add-on szoftvereket az /opt-ba kell telep?ened alap駻telmezetten). Tov畸bi inform當i?at a cikkben 駸 az LSB honlapj疣 tal疝sz.


6.2. libhello.h f疔l

/* libhello.h - demonstrate library use. */


void hello(void);


6.3. demo_use.c f疔l

/* demo_use.c -- demonstrate direct use of the "hello" routine */

#include "libhello.h"

int main(void) {
 hello();
 return 0;
}


6.4. script_static f疔l

#!/bin/sh
# Static library demo

# Create static library's object file, libhello-static.o.
# I'm using the name libhello-static to clearly
# differentiate the static library from the
# dynamic library examples, but you don't need to use
# "-static" in the names of your
# object files or static libraries.

gcc -Wall -g -c -o libhello-static.o libhello.c

# Create static library.

ar rcs libhello-static.a libhello-static.o

# At this point we could just copy libhello-static.a
# somewhere else to use it.
# For demo purposes, we'll just keep the library
# in the current directory.

# Compile demo_use program file.

gcc -Wall -g -c demo_use.c -o demo_use.o

# Create demo_use program; -L. causes "." to be searched during
# creation of the program.  Note that this command causes
# the relevant object file in libhello-static.a to be
# incorporated into file demo_use_static.

gcc -g -o demo_use_static demo_use.o -L. -lhello-static

# Execute the program.

./demo_use_static


6.5. script_shared f疔l

#!/bin/sh
# Shared library demo

# Create shared library's object file, libhello.o.

gcc -fPIC -Wall -g -c libhello.c

# Create shared library.
# Use -lc to link it against C library, since libhello
# depends on the C library.

gcc -g -shared -Wl,-soname,libhello.so.0 \
    -o libhello.so.0.0 libhello.o -lc

# At this point we could just copy libhello.so.0.0 into
# some directory, say /usr/local/lib.

# Now we need to call ldconfig to fix up the symbolic links.
 
# Set up the soname.  We could just execute:
# ln -sf libhello.so.0.0 libhello.so.0
# but let's let ldconfig figure it out.

/sbin/ldconfig -n .

# Set up the linker name.
# In a more sophisticated setting, we'd need to make
# sure that if there was an existing linker name,
# and if so, check if it should stay or not.

ln -sf libhello.so.0 libhello.so

# Compile demo_use program file.

gcc -Wall -g -c demo_use.c -o demo_use.o

# Create program demo_use.
# The -L. causes "." to be searched during creation
# of the program; note that this does NOT mean that "."
# will be searched when the program is executed.

gcc -g -o demo_use demo_use.o -L. -lhello

# Execute the program.  Note that we need to tell the program
# where the shared library is, using LD_LIBRARY_PATH.

LD_LIBRARY_PATH="." ./demo_use


6.6. demo_dynamic.c f疔l

/* demo_dynamic.c -- demonstrate dynamic loading and
   use of the "hello" routine */


/* Need dlfcn.h for the routines to
   dynamically load libraries */
#include <dlfcn.h>

#include <stdlib.h>
#include <stdio.h>

/* Note that we don't have to include "libhello.h".
   However, we do need to specify something related;
   we need to specify a type that will hold the value
   we're going to get from dlsym(). */

/* The type "simple_demo_function" describes a function that
   takes no arguments, and returns no value: */

typedef void (*simple_demo_function)(void);


int main(void) {
 const char *error;
 void *module;
 simple_demo_function demo_function;

 /* Load dynamically loaded library */
 module = dlopen("libhello.so", RTLD_LAZY);
 if (!module) {
   fprintf(stderr, "Couldn't open libhello.so: %s\n",
           dlerror());
   exit(1);
 }

 /* Get symbol */
 dlerror();
 demo_function = dlsym(module, "hello");
 if ((error = dlerror())) {
   fprintf(stderr, "Couldn't find hello: %s\n", error);
   exit(1);
 }

 /* Now call the function in the DL library */
 (*demo_function)();

 /* All done, close things cleanly */
 dlclose(module);
 return 0;
}


6.7. script_dynamic f疔l

#!/bin/sh
# Dynamically loaded library demo

# Presume that libhello.so and friends have
# been created (see dynamic example).

# Compile demo_dynamic program file into an object file.

gcc -Wall -g -c demo_dynamic.c

# Create program demo_use.
# Note that we don't have to tell it where to search for DL libraries,
# since the only special library this program uses won't be
# loaded until after the program starts up.
# However, we DO need the option -ldl to include the library
# that loads the DL libraries.

gcc -g -o demo_dynamic demo_dynamic.o -ldl

# Execute the program.  Note that we need to tell the
# program where get the dynamically loaded library,
# using LD_LIBRARY_PATH.

LD_LIBRARY_PATH="." ./demo_dynamic


http://www.tldp.org.

  • Tool Interface Standards (TIS) biztos疊: "Executable and Linkable Format (ELF)" (ez jelenleg egy fejezete a Portable Formats Specification Version 1.1.-nek ugyanett? a bizotts疊t?). CLASS="SECT1" >


    8. Copyright and License

    This document is Copyright (C) 2000 David A. Wheeler. It is covered by the GNU General Public License (GPL). You may redistribute it without cost. Interpret the document's source text as the ``program'' and adhere to the following terms:

    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

    These terms do permit mirroring by other web sites, but please:

    The first two points primarily protect me from repeatedly hearing about obsolete bugs. I do not want to hear about bugs I fixed a year ago, just because you are not properly mirroring the document. By linking to the master site, users can check and see if your mirror is up-to-date. I'm sensitive to the problems of sites which have very strong security requirements and therefore cannot risk normal connections to the Internet; if that describes your situation, at least try to meet the other points and try to occasionally sneakernet updates into your environment.

    By this license, you may modify the document, but you can't claim that what you didn't write is yours (i.e., plagiarism) nor can you pretend that a modified version is identical to the original work. Modifying the work does not transfer copyright of the entire work to you; this is not a ``public domain'' work in terms of copyright law. See the license for details, in particular noting that ``You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.'' If you have questions about what the license allows, please contact me. In most cases, it's better if you send your changes to the master integrator (currently David A. Wheeler), so that your changes will be integrated with everyone else's changes into the master copy.