How does a C compiler find that -lm is pointing to the file libm.a?

How does the compiler find the libraries? It has a built-in collection of library paths that are searched. As an example, GCC will tell you its search paths if asked:
install: /usr/lib/gcc/i686-redhat-linux/4.4.4/
programs: =/usr/libexec/gcc/i686-redhat-linux/4.4.4/:/usr/libexec/gcc/i686-redhat-linux/4.4.4/:/usr/libexec/gcc/i686-redhat-linux/:/usr/lib/gcc/i686-redhat-linux/4.4.4/:/usr/lib/gcc/i686-redhat-linux/:/usr/libexec/gcc/i686-redhat-linux/4.4.4/:/usr/libexec/gcc/i686-redhat-linux/:/usr/lib/gcc/i686-redhat-linux/4.4.4/:/usr/lib/gcc/i686-redhat-linux/:/usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../i686-redhat-linux/bin/i686-redhat-linux/4.4.4/:/usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../i686-redhat-linux/bin/
libraries: =/usr/lib/gcc/i686-redhat-linux/4.4.4/:/usr/lib/gcc/i686-redhat-linux/4.4.4/:/usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../i686-redhat-linux/lib/i686-redhat-linux/4.4.4/:/usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../i686-redhat-linux/lib/:/usr/lib/gcc/i686-redhat-linux/4.4.4/../../../i686-redhat-linux/4.4.4/:/usr/lib/gcc/i686-redhat-linux/4.4.4/../../../:/lib/i686-redhat-linux/4.4.4/:/lib/:/usr/lib/i686-redhat-linux/4.4.4/:/usr/lib/

You can add more library search paths by using the "-L /path" option.

In those paths, it first searches for "dynamic libraries" which are named with a ".so" extension. It then searches for static libraries with a ".a" extension. It always adds "lib" to the front of the name.

https://stackoverflow.com/questions/3907498/how-does-a-c-compiler-find-that-lm-is-pointing-to-the-file-libm-a

How does a C compiler find that -lm is pointing to the file libm.a?相关推荐

  1. gmp4.3.2 安装时 ./configure报错: error: could not find a working compiler

    今天在虚拟机上想安装gcc4.9.3 但貌似有三个依赖,那就顺序装吧. 装到gmp的时候.怎么都configure不过去,各种查各种不行,但是我之前在别的机器装成功过. 刚开始一直以为是某个编译程序没 ...

  2. gmp4.3.2 安装 configure: error: could not find a working compiler

    今天在虚拟机上想安装gcc4.7.2 但貌似有三个依赖. 那就顺序装吧. 装到gmp的时候.怎么都configure不过去,各种查各种不行,但是我之前在别的机器装成功过. 刚开始一直以为是某个编译程序 ...

  3. 五大学科竞赛(三)-o2 -lm编译选项

    使用 math.h 必须使用 -lm 参数指定指定链接到 libm.so 使用 O2 优化也能过编译的原因是,在优化的过程中, sqrt(a) 会被直接优化成最终的常数,所以这个时候其实并不需要真正链 ...

  4. 327 - Evaluating Simple C Expressions

    2019独角兽企业重金招聘Python工程师标准>>> 题意: C 表达式运算, 变量为 a-z, 代表运算数为 1-26; 运算符包括 +, -, ++, --; 要求输出原表达式 ...

  5. 445 - Marvelous Mazes

    2019独角兽企业重金招聘Python工程师标准>>> 题意: 根据输入画出迷宫.输入的字符串中包含字符和数字, 其中数字表示其后紧跟着的字符的重复次数(若连续出现两个以上的数字, ...

  6. 127 - Accordian Patience

    2019独角兽企业重金招聘Python工程师标准>>> 题意: 移牌游戏,按以下规则: 1. 从左向右, 考虑每张牌, 若某张牌与其左边第1张或左边第3张是同一个牌号或花色, 则就把 ...

  7. 297 - Quadtrees

    2019独角兽企业重金招聘Python工程师标准>>> 题意: 1. 两张 32*32 像素的图像进行叠加, 像素只有黑白两种颜色, 按以下规则叠加: (1). 黑+黑=黑; (2) ...

  8. An Introduction to GCC - 2 Compiling a C program (编译 C 程序)

    An Introduction to GCC - 2 Compiling a C program (编译 C 程序) for the GNU Compilers gcc and g++ Brian G ...

  9. maven scala plugin 实现jvmArgs,执行过程原理解析笔记

    scala-maven-plugin 构建scala,springboot工程 我们在使用maven构建scala工程的时候, 要使用scala-maven-plugin插件,常规配置如下 : < ...

  10. linux gcc编译参数顺序问题

    初学Linux C编程遇到编译出错 运行下面编译命令,出错 gcc -g -W -Wall -pthread  -lcrypto -o httpd httpd.c 错误信息: /tmp/ccYw8W8 ...

最新文章

  1. 位图排序 大数据_干货分享:大话12种排序算法
  2. spring mvc学习(22):/textpath/*/helen
  3. 【Flink】Flink 提交任务到yarn报错 proxy provider ConfiguredFailoverProxyProvider NetUtils.getSocketAddressS
  4. 蚂蚁集团,打响2022反内卷第一枪?
  5. 网站改版进行时,需要注意的
  6. python实现判断一个字符串是否是合法IP地址
  7. Atitit 智能云网络摄像机的前世今生与历史 优点  密码默认888888
  8. 【HDU 4699】Editor【栈】
  9. python群发邮件 不进垃圾箱_邮件群发不进垃圾箱
  10. YOLOX训练代码分析3-损失函数
  11. c语言字符类型中int表示什么,int表示什么数据类型
  12. 将家安在天涯,将这儿作为副战
  13. 如何设置本电脑中的mysql让别人的电脑连接
  14. 【Python】python 程序示例
  15. 给PowerPoint按钮加上提示文字
  16. 我们的UED设计流程及方法
  17. Firefox火狐快捷键
  18. 经久不衰的运输层协议 —— TCP协议
  19. 16位汇编编译报错和解决办法
  20. ICT 2017 | 以色列驻华大使馆商务官欧美雅: 以色列人一直都在追求创新

热门文章

  1. Flutter上传多张图片
  2. Docker资源控制的Cgroup--CPU权重等--Block IO、bps和iops 的限制详细操作
  3. iOS开发基础-序列帧动画之Tom猫
  4. git切换远程分支为develop
  5. 3029. 【NOIP2011DAY2】观光公交
  6. 数字孪生的思考 05 - VAM/XR
  7. 记YY的一次面试经历
  8. 华为云教程(云备份CBR)
  9. 毕业N年后,请不要像我一样被档案烦死——转自一位已经毕业的学姐
  10. (七) 立创EDA之PCB设计示例