在windows下一直用vs2008,现在我在linux下装了个qt creator集成开发环境,准备来写标准C/C++程序。
按照File-->New file or project-->QT C++ Project-->QT Console Application
然后写了一个hello word的标准c++程序。
#include <iostream>
using namepace std;
int main(int argc, char *argv[])
{
cout<<"hello world"<<endl;
getchar();
}
可是编译compile out栏输出很多错误信息
- C/C++ code
Running build steps for project test...Configuration unchanged, skipping qmake step.Starting: "/usr/bin/make" -wmake: Entering directory `/home/fupeng/Desktop/cproject/test-build-desktop'g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../test -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -I../test -I. -o main.o ../test/main.cpp../test/main.cpp:2: error: expected nested-name-specifier before ‘namepace’../test/main.cpp:2: error: ‘namepace’ has not been declared../test/main.cpp:2: error: expected ‘;’ before ‘std’../test/main.cpp:2: error: expected constructor, destructor, or type conversion before ‘;’ token../test/main.cpp: In function ‘int main(int, char**)’:../test/main.cpp:6: error: ‘cout’ was not declared in this scope../test/main.cpp:6: error: ‘endl’ was not declared in this scope../test/main.cpp:7: error: ‘getchar’ was not declared in this scope../test/main.cpp: At global scope:../test/main.cpp:4: warning: unused parameter ‘argc’../test/main.cpp:4: warning: unused parameter ‘argv’make: Leaving directory `/home/fupeng/Desktop/cproject/test-build-desktop'make: *** [main.o] Error 1The process "/usr/bin/make" exited with code %2.Error while building project test (target: Desktop)When executing build step 'Make'
------解决方案--------------------
namepace --> namespace