Chinaunix

标题: linux下用eclipse编写c/c++关于代参数的问题 [打印本页]

作者: thrinity    时间: 2009-10-16 10:04
标题: linux下用eclipse编写c/c++关于代参数的问题
在linux下用eclipse编写c/c++如果不呆参数还好 带就有问题 比分说我自己写了个头文件封装成库函数 一个源文件用到了这个库函数 在终端编译的时候就是g++ -o test test.c -lhello 但在eclipse中通不过编译 因为找不到头文件中的函数 所以想问一下怎么用eclipse来运行这种project 谢谢了
作者: egametang    时间: 2009-10-16 11:07
你可以右键点你的project->properties->c/c++ builder->settings里面添加编译器和链接器的参数。
比如你这个-lhello库就可以在linker的libraries添加,也可添加hello库的搜索路径-L

eclipse也可以使用自己的makefile,建立c/c++项目时,选择makefile项目即可,它会使用你project目录
下的makefile
作者: thrinity    时间: 2009-10-16 11:42
标题: 回复 #2 egametang 的帖子
我那样作了 还是不行阿
eclipse的
Building target: last
Invoking: GCC C++ Linker
g++  -o"last"  ./src/test.o   -lhdr
./src/test.o: In function `main':
/home/arthur/workspace2/last/Debug/../src/test.c:14: undefined reference to `err_sys'
collect2: ld returned 1 exit status
make: *** [last] Error 1
终端的


[root@localhost src]# g++ -o last test.c -lhdr
[root@localhost src]# ./last
hello: Success




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2