Getting Started

/usr/include   you need headerfiles. For c these are always located in /usr/include and subdirectories andsubdirectories thereof

gcc  -I/home/chenpenghello.c   direct the compiler to look in the directory/home/chenpeng,as well as the standard places

 

 

staticlibrary

     Standardsystem libraries are usually stored in /liband /usr/lib.

    .a  for traditional, static libraries

    .so for shared libraries(seethe following)

 

gcc –o fred fred.c /usr/lib/libm.a   tells the compiler to compile file fred.c, call the resulting programfile fred, and search the m library in addition to the standard C                                                 library  toresolve references to functions. A similar result is achieved with thefollowing command:

gcc –o fredfried.c –lm    in this case /usr/lib, compiler willautomatically choose the shared library

gcc –o x11fred –L/usr/openwin/lib x11fred.c -1X11  

              addto the search directories by using the –L(uppercase letter) flag to thecompiler. will compile and link a program called x11fred using the version of                   the library libX11 found in the /usr/openwin/lib directory

gcc –c bill.c fred.c    individually to produce object files.

ar crv libfoo.a bill.o fred.o     create the archive and add our objectfiles to it

gcc –o program program.o libfoo.a

ranlib libfoo.a     a table ofcontent be created for the library, speed access to archives

 

sharedlibraries

    one disadvantage of staticlibraryies is that when you run many applications at

    the same time and they all use functions from the samelibrary, you may end up white many copyies of the same functions in memory andindeed many copies in program files themselves

    shared libraries canovercome this disadvantage.

 

    On a typical Linux system,the shared version of the standard math library is /lib/libm.so.When a program uses a shared library, it islined in such a way that it doesn’t contain function code itself, butreferences to shared code that will be made available atrun time.

    We can seewhich shared libraries are required by a program by running the utility ldd. the following:

$ ldd program

      linux-vdso.so.1 =>  (0x00007ffff6fff000)

      libc.so.6 => /lib64/libc.so.6 (0x0000003c51400000)

      /lib64/ld-linux-x86-64.so.2 (0x0000003c50c00000)

   shared libraries are similar to dynamic-link libraries used underwindows. the .a libraries are similar to .LIB files.

 

GettingHelp

man gcc

info gcc      The info system also contains its ownhelp page in info form pages,of course.If you type Ctrl+H ,you’ll be presentedwith som help that includes a                        turorial on using info.

     The man commandprovides access to the online manual pages.

     The GNU software suite and some other free software use an onlinedumentation system called info.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值