- 论坛徽章:
- 0
|
代码:
[root@mail c]# less test.cpp
#include <iostream>
#include <string>
using namespace std;
int main(){
string user_name;
cout << "Please input your name: ";
cin >> user_name;
cout << "Hello, "
<< user_name
<< " ...and goodbye!\n";
return 0;
}
编译过程:
[root@mail c]# g++ -Wall -O2 -c test.o test.cpp
g++: test.o: No such file or directory
请问:为什么会出现这个“No such file or directory”呢,我试验过,如果写makefile的话,编译多个.o,就会报makefile错误,因为不能连续的把.o文件编译出来,每次都会报这个错误,但是还能把.o编译出来,很奇怪?
以前都是用gcc,写C程序,初学C++,感觉g++应该很多参数都和gcc一样吧,难道我用错了,请指教! |
|