- 论坛徽章:
- 0
|
原 C/C++ 论坛 FAQ,尚未整理。
刚接触 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
复制代码 |
|