1 / 5

Static Libraries

Static Libraries. ธวัชชัย เอี่ยมไพโรจน์. Static Libraries. It is the simplest form of library. It is a collection of object files kept together in a ready-to-use form. To use its functions: include the header that declares the function. Compile and link to the library.

Download Presentation

Static Libraries

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Static Libraries ธวัชชัย เอี่ยมไพโรจน์

  2. Static Libraries • It is the simplest form of library. • It is a collection of object files kept together in a ready-to-use form. • To use its functions: • include the header that declares the function. • Compile and link to the library. • Know as “archives” name end with .a such as cgihtml.a • Use “ar” command to create the static library.

  3. Steps to create a static library. • Create functions in files, such as: fred.c, bill.c then compile to get its object file like: fred.o bill.o etc. • Create a header file which include function prototype of all functions in the library. • Test the completeness of the object files. • Use command as: • ar crv liba bill.o fred.o • On some systems must use: (No need for Linux.) • ranlib lib.a

  4. Disadvantage of static libraries. • Many copies of the same functions in memory. • UNIX also support shared libraries. (Not in our scope!). • Named: • /lib/libc.so.N (N represent version number.) • /lib/libc.sa (Reference to share codes, not library itself.) • Use command: (See which share library need by program). • ldd /usr/local/apache/bin/httpd

  5. Lab01 • กำหนด files ต่างๆ ไว้ให้ที่: • http://lecture.compsci.buu.ac.th/~f44213/samples/lab01/ • ให้เขียน Makefile เพื่อสร้าง static library ชื่อเดียวกับ loginID ของท่านตามด้วย .a เช่น sc439999.a จาก files ที่กำหนดให้ • ตรวจดูขนาดของ file ว่าเป็น 44578 bytes แล้วเก็บไว้ที่ web directory รายวิชานี้ของท่าน • เขียนรายงานผลการศึกษาทดลองครั้งนี้แล้วส่งมากับ mail ที่ • f44213@lecture.compsci.buu.ac.th

More Related