atfa 发表于 2003-6-4 00:24:57

(For newbie)Linux 编程环境常见问题[ZT]

刚接触 Linux/UN*X 编程的朋友们对 Linux/UN*X 编程环境和有关工具还不太熟悉。
这里总结有关 Linux/UN*X 编程环境的一些最基本的常见问题。 Hope it helps.


1. a.out 不能运行
2. gdb 不能调试
3. c++ 程序通不过编译
4. undefined reference to 'xxxx'
5. make/Makefile 不能工作


1Q. 我用 gcc hello.c 编译成了 a.out.
但运行 a.out 时,系统提示 "bash: a.out: command not found".

1A. $ ./a.out


2Q. 我用 gdb 调试程序时,无法用 list 命令显示源文件,总是提示 "init.c: No such file or directory"

2A. 编译时加上 -g 选项。


3Q. 我写了个最简单的 "hello, world" 的 c++ 程序,但无法用 gcc编译,
总是有 "undefined reference to `std::cout'" 等错误提示。

3A. 用 g++ 编译 c++ 程序, ie. $ g++ foo.cpp


4Q. 为何编译程序时得到 "undifined reference to 'xxxx'" 错误提示?

4A. 1) 见问题 3。and/or
2) 缺少某个库的连接。(ie. -lpthread, -lcrypt)


5Q. 用 make/Makefile 时,提示 "missing separator. Stop."

5A. Makefile 要求每条命令前都要有 <Tab>. ie,
--------------------------8<--------------------------------
Target: Dependence
<Tab> Command
-------------------------->8--------------------------------


Anything i've missed?



Vim 中文文档
http://vcd.cosoft.org.cn

伤心小箭0310 发表于 2006-10-30 10:33:36

有心人!!
页: [1]
查看完整版本: (For newbie)Linux 编程环境常见问题[ZT]