您的位置:首页 > 其它

Getting Started

2014-11-15 22:58 239 查看
/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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: