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.
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.
相关文章推荐
- ArcGis Modelbuilder: getting started
- Getting Started 系列 - Project 檔案說明
- Android Getting Started
- 【翻译 windbg-2】Getting started with windbg - part I (第二部分 )
- FmodEX 编程人门(转)-- Fmod文档中GETTING STARTED的翻译
- Getting Started(WPF)
- Getting Started
- MongoDB权威指南(1)- Getting Started
- Getting Started
- Hive官方手册翻译(Getting Started)
- JStockChart -- Getting Started(Timeseries) 时序图
- libjingle :Getting Started
- Creating Your First Mac App--Getting Started
- Getting Started(v8 hello world)
- Windows 8 JavaScript Metro Application–Getting Started
- struct2 tags - Getting Started
- go, Getting Started, Hello world
- CritterAI官方文档翻译【Getting Started with Unity】
- Xamarin Getting Started翻译系列二--Activity生命周期
- (译)Getting Started——1.3.1 Incorporating the Data(合并数据)