Invoke dynamic libraries and static libraries in AIX environments

Source: Internet
Author: User

Prerequisite Knowledge:

Dynamic library suffix. So static library suffix. A

-c only compile not link

-O Specify Output name

-L Specify the lookup path for the link library

-l Specifies the link's library name

The-I file contains the header file, I followed the path of the lookup header file

The above can meet the compilation target

Generate. A file

Command AR

Q: Quick append. Add new modules to the end of the library

T view the members contained in the. a file

x extracts the members from the. A file, and if you do not specify the extracted members, it is extracted (note: Do not delete the members in the archive)

Cases:

G2dbt1:/wxp/so_a#ar T LIBHU.A
Libhu.o
Cmaps.o
sccsid.o
libhu_r.o
libhu32_r.o
libhu32.o

G2dbt1:/wxp/so_a#ar x libhu.a LIBHU.O
G2dbt1:/wxp/so_a#ls
LIBHU.A LIBHU.O


D Delete a member from a module

Cases:

G2dbt1:/wxp/so_a#ar D libhu.a LIBHU.O
G2dbt1:/wxp/so_a#ar T LIBHU.A
Cmaps.o
sccsid.o
libhu_r.o
libhu32_r.o
libhu32.o

M moves the members in the module in the order of a (moved to the back of the specified member) b (moves to the front of the specified module), and defaults to the last side if you do not specify the position to move

G2DBT1:/WXP/SO_A#AR-MB CMAPS.O libhu.a LIBHU.O
G2dbt1:/wxp/so_a#ar T LIBHU.A
Libhu.o
Cmaps.o
sccsid.o
libhu_r.o
libhu32_r.o
libhu32.o

V list additional information during execution

According to the above, if you create a. A file, the command is as follows:

/enpc/wxp/so_a$cc-c SAYHELLO.C
/enpc/wxp/so_a$ls
HELLO.C sayhello.c SAYHELLO.O
/ENPC/WXP/SO_A$AR-RV LIBHELLO.A SAYHELLO.O
Ar:creating an archive file LIBHELLO.A.
a-sayhello.o
/enpc/wxp/so_a$ls
HELLO.C libhello.a sayhello.c sayhello.o


command of function call. A

/ENPC/WXP/SO_A$CC hello.c-l./-lhello-o SayHello
/enpc/wxp/so_a$ls
hello.c libhello.a SayHello sayhello.c sayhello.o
/enpc/wxp/so_a$./sayhello
Say hello
/ENPC/WXP/SO_A$LDD SayHello
SayHello needs:
/USR/LIB/LIBC.A (SHR.O)
/unix
/USR/LIB/LIBCRYPT.A (SHR.O)


There's no libhello.a file in LDD's order.

static files, whether or not it is not important.


To produce a dynamic file:


Use the makefile file to produce a static library and invoke success


The file is not very successful yet.

Clean:
-rm *.o
-rm *.a

all:main.o libhello.a
Cc-o all main.o-l./-lhello
  
Main. O:HELLO.C
cc-c hello.c-o main.o
  
libhello.a:sayhello.o
Ar-rv libhello.a sayhello.o
& NBSP;&NBSP
sayhello.o:sayhello.c
cc-c sayhello.c-o sayhello.o

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.