gccintro

本文探讨了GCC编译器在链接静态库与动态库时的行为特点,包括如何指定链接选项、解决库依赖问题及如何正确指定搜索路径等关键实践。文章还介绍了虚拟内存机制在节省内存和磁盘空间方面的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.’. The function sqrt is not defined in the program or the default library ‘libc.a’, and the compiler does not link to the file ‘libm.a’ unless it is explicitly selected.

My Word: gcc won't link the static library without explicitly linking it 's a dumbass

 

2.A large program will typically use many ‘-l’ options to link libraries such as the math library, graphics libraries and networking libraries.

like this gcc -Wall calc.c -lm -o calc

My word: it has been convenient a little bit but it 's not convenient at all .

3.For example, a program ‘data.c’ using the GNU Linear Programming library ‘libglpk.a’, which in turn uses the math library ‘libm.a’, should be compiled as, $ gcc -Wall data.c -lglpk -lm

My Word : the order is looking afterward.

4The directories on these paths are searched in order, from first to last in the two lists above.(1) For example, a header file found in ‘/usr/local/include’ takes precedence over a file with the same name in ‘/usr/include’. Similarly, a library found in ‘/usr/local/lib’ takes precedence over a library with the same name in ‘/usr/lib’.

My Word : the gcc maker like the order or the unix like system file system maker love that order and  that's the question

5.$ export C_INCLUDE_PATH This directory will be searched after any directories specified on the command line with the option ‘-I’, and before the standard default directories ‘/usr/local/include’ and ‘/usr/include’. The shell command export is needed to make the environment variable available to programs outside the shell itself, such as the compiler—it is only needed once for each

My word: the shell loves the gcc so it just exports thost motherfucker varibles;

 

6.My conclusion : the header file is meant for decoration. so most probably we don't need to add it to the command line .

7.Most operating systems also provide a virtual memory mechanism which allows one copy of a shared library in physical memory to be used by all running programs, saving memory as well as disk space.

My Word : What does the virtual memory really mean int this case

 

8.In this case, when the compiler searches for the ‘libgdbm’ library in the link path, it finds the following two files in the directory ‘/opt/gdbm-1.8.3/lib’: $ cd /opt/gdbm-1.8.3/lib $ ls libgdbm.* libgdbm.a libgdbm.so Consequently, the ‘libgdbm.so’ shared object file is used in preference to the ‘libgdbm.a’ static library.

My word : two libraries that 's impressive

9 the safe way to “comment out” a section of code containing comments is to surround it with the preprocessor directive #if 0 ... #endif

My Word : I like ( if 0  end if) kind of things

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值