Linux C 编译错误 “un
来源:互联网 发布:上海大数据公司排名 编辑:程序博客网 时间:2024/05/18 01:20
- (.text+0x13):
undefined reference to `func'
1.
- gcc
-c test.c - gcc
–c main.c
- main.o:
In function `main': - main.c:(.text+0x7):
undefined reference to `test' - collect2:
ld returned 1 exit status
- gcc
-o main main.o test.o
- gcc
-o main main.c //缺少test()的实现文件
需要改成如下形式才能成功,将test()函数的实现文件一起编译。
- gcc
-o main main.c test.c //ok,没问题了
2.
- gcc
-c test.c - ar
-rc test.a test.o
- gcc
-c main.c
- gcc
-o main main.o
- /tmp/ccCPA13l.o:
In function `main': - main.c:(.text+0x7):
undefined reference to `test' - collect2:
ld returned 1 exit status
- gcc
-o main main.o ./test.a //注:./ 是给出了test.a的路径
- gcc
-o main main.c ./test.a //同样,如果不加test.a也会报错
3.
- gcc
-c func.c - gcc
-c test.c - gcc
-c main.c
- ar
–rc func.a func.o - ar
–rc test.a test.o
- gcc
-o main main.o test.a
- test.a(test.o):
In function `test': - test.c:(.text+0x13):
undefined reference to `func' - collect2:
ld returned 1 exit status
- gcc
-o main main.o test.a func.a
4 多个库文件链接顺序问题
- gcc
-o main main.o func.a test.a
- test.a(test.o):
In function `test': - test.c:(.text+0x13):
undefined reference to `func' - collect2:
ld returned 1 exit status
5. 在c++代码中链接c语言的库
- gcc
-c test.c - ar
-rc test.a test.o
- g++
-o main main.cpp test.a
- /tmp/ccJjiCoS.o:
In function `main': - main.cpp:(.text+0x7):
undefined reference to `test()' - collect2:
ld returned 1 exit status
- g++
-o main main.cpp test.a
- Linux C 编译错误 “un
- linux c 的错误判断
- em的错误 <转载>
-  
-
- linux c 的错误判断与陷阱
- 编译错误 --- does&nbsp…
- C++ static_cast
- linux centos7 编译安装mysql 5.6
- linux启动错误 Invalid module for…
- Objective C 监听 通知
- fzu 1759 A^B % C
- 【转载】linux C …
- 编译链接原理 C++
- C standard library contents
- C++ keyword: delete note
- C++ Log File Class
- C++ 使用 string 型態
- 无法找到“XXX.exe”的调试信息,或…
- SQL关联查询图解
- 坐班族轻敲胆经防便秘
- linux 中的软件安装位置(转载)
- [深度学习]RCNNs系列(3)Fast RCNN介绍
- Linux C 编译错误 “un
- 安装arm-linux-gcc环境变量…
- HOG(Histogram of Oriented Gradient)
- gcc -l参数和-L参数(转载)
- SpringMVC中ModelAndView的使用
- gcc优化编译
- linux用gdb调试程序(转载)
- npm install 命令知多少
- 强制退出mac程序的方法(转载)