相关学习资料
C语言中文网:http://c.biancheng.net/view/7930.html
目录
一、gcc参数 (严格区分大小写)
常用参数
https://blog.csdn.net/qq_59084325/article/details/125726056
https://blog.csdn.net/qq_59084325/article/details/125726056
- -s
https://zhidao.baidu.com/question/145908113.html
gcc 编译选项 -s 可以裁剪执行程序的信息,删除可执行文件中所有符号表和重新定位信息,以压缩可执行文件,导致gdb调试无效,使用命令 file excfilename可以看到有strip
库相关
-
shared
指定生成动态链接库 -
static
指定生成静态链接库 -
L
要链接的库所在目录 -
l
指定链接时需要的库,隐含命名规则,即自动在前加lib,在后加.a或.so确定库文件名 -
-Wl,-rpath=
添加一个运行时库文件搜索路径
https://blog.csdn.net/XFH1207/article/details/109771969
头文件相关
-
查看gcc应用层编程的默认头文件搜索路径
https://www.cnblogs.com/lishanyang/p/16295690.html
1.For C:gcc -xc -E -v -
2.For C++:
gcc -xc++ -E -v -
配置相关
- std
设置C语言版本 g++ -std=c11 Test.cpp -o Test
优化相关
-
-fprofile-arcs -ftest-coverage
和代码覆盖率相关的参数:https://zhuanlan.zhihu.com/p/353112109
https://blog.csdn.net/u014470361/article/details/103447678
调试相关
- -g
编译可调试的文件
其它
- -D宏定义
https://www.coder.work/article/6817517
-DKey=Value
,如果Value是字符串,如果字符串中有空格,则字符串要用单引号括起来。
二、gcc编译常见错误整理
https://blog.csdn.net/weixin_43679037/article/details/126047073
- undefined reference to `dlopen'
https://blog.csdn.net/qq_27870421/article/details/98968449
注意g++ main.cpp -ldl
与
add_executable(pwc main.cpp)
TARGET_LINK_LIBRARIES(pwc dl)
还是有区别的,前者针对单个文件,后者针对整个工程。
0 条评论