简体   繁体   English

带有ubuntu 12.04配置的eclipse 4.2 cdt

[英]eclipse 4.2 cdt with ubuntu 12.04 configuration

I am running Eclipse CDT (Eclipse v. 4.2) on Ubuntu 12.04. 我在Ubuntu 12.04上运行Eclipse CDT(Eclipse v。4.2)。 When I create a C++ project (Under Project type -> Executable -> Hello World C++ Project) and select the Linux GCC toolchain, the standard hello world application compiles and runs just fine. 当我创建一个C ++项目(在Project type下-> Executable-> Hello World C ++ Project)并选择Linux GCC工具链时,标准的hello world应用程序可以编译并运行良好。 When I try to create an Empty Project (from the same menu as before), selecting the Linux GCC toolchain also, it brings several build errors: 当我尝试创建一个空项目时(从与以前相同的菜单中),同时选择Linux GCC工具链,会带来一些构建错误:

   make:***[tst] Error 1
   Symbol 'cout' could not be resolved
   Symbol 'endl' could not be resolved
   Symbol 'std' could not be resolved
   undefined reference to 'main'

When I compare the path settings (Properties -> C/C++ Build, and C/C++ General) for the .cpp file generated by "Hello World C++ Project", and for the .cpp file added to the "Empty Project" they have the same configurations and settings, so I am not sure why the empty project isn't detecting the standard library and compiling. 当我比较“ Hello World C ++项目”生成的.cpp文件和添加到“空项目”的.cpp文件的路径设置(属性-> C / C ++构建和C / C ++常规)时,它们具有相同的配置和设置,所以我不确定为什么空白项目没有检测到标准库并进行编译。 All the files in the includes folder are also the same. include文件夹中的所有文件也都相同。 This also happens on my Windows 7 (MingW compiler) install, and on my MacOS X install. 在Windows 7(MingW编译器)安装和MacOS X安装中也会发生这种情况。 For now I can just create my projects as a "Hello World C++ project", get rid of the text and code what I want, but I am really curious as to how to set it up from scratch, especially since it is my understanding that creating an "Empty Project" under the Executable folder (as opposed to creating a Makefile project) should include a makefile and all the necessary paths (as long as the proper toolchain is selected?). 现在,我可以将我的项目创建为“ Hello World C ++项目”,摆脱我想要的文本和代码,但是我真的很好奇如何从头开始进行设置,特别是因为据我所知在Executable文件夹下创建“空项目”(与创建Makefile项目相反)应包括一个makefile和所有必要的路径(只要选择了正确的工具链?)。

The actual build error from the CDT console is: CDT控制台的实际构建错误是:

    20:49:26 **** Incremental Build of configuration Debug for project tst ****
    make all 
    Building target: tst
    Invoking: GCC C++ Linker
    g++  -o "tst"  ./src/test.o   
    /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
    (.text+0x20): undefined reference to `main'
    collect2: ld returned 1 exit status
    make: *** [tst] Error 1

    20:49:26 Build Finished (took 62ms)

The code I'm trying to run is just the default hello world code generated by eclipse: 我尝试运行的代码只是eclipse生成的默认hello world代码:

   #include <iostream>
   using namespace std;

   int main() {
   cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
   return 0;
   }

Thanks in advance. 提前致谢。

I've seen that some of the Ubuntu 12.04 DVD's sold in Magazines do not install gnu G++ by default. 我已经看到,杂志中出售的某些Ubuntu 12.04 DVD默认情况下不安装gnu G ++。 Go to the Ubuntu Software Center and install G++ (GNU C++ compiler tool chain). 转到Ubuntu软件中心并安装G ++(GNU C ++编译器工具链)。 After installation right click on your project's name in the Eclipse Project Explorer on the left side of the IDE. 安装后,在IDE左侧的Eclipse Project Explorer中右键单击您的项目名称。 Select Rebuild under the Index item. 在索引项下选择重建。 This should resolve the issue with the iostream include, etc. 这应该可以解决iostream include等问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ubuntu 12.04 eclipse中的“无此文件或目录”错误 - “No such file or directory” error in ubuntu 12.04 eclipse 升级后,Ubuntu 12.04上的C ++ Eclipse无法解析 - C++ Eclipse on Ubuntu 12.04 unable to resolve after upgrade 如何在Ubuntu中使用Eclipse CDT调试C ++静态库? - How to debug a C++ static library using Eclipse CDT in Ubuntu? 链接器错误,在Ubuntu 15.04上使用OpenCV和Eclipse CDT - Linker Error, Using OpenCV and Eclipse CDT on ubuntu 15.04 是否可以根据构建配置更改 Eclipse CDT 中的代码? - Is it possible to alter code in Eclipse CDT based on build configuration? 如何获取从Eclipse CDT中的构建配置中排除的文件? - How to get back a file that was excluded from a build configuration in Eclipse CDT? Ubuntu 12.04上的OpenGL 4教程 - Tutorial OpenGL 4 on Ubuntu 12.04 OpenCV C ++代码在终端运行良好但从eclipse运行时出错 - Ubuntu 12.04 - OpenCV C++ code runs fine in terminal but error in running from eclipse - Ubuntu 12.04 在Ubuntu 12.04上设置Google Test以在Eclipse中运行C / C ++ Test Runner插件 - Setting Up Google Test to Run through C/C++ Test Runner Plug-In in Eclipse on Ubuntu 12.04 在Ubuntu 18.04上运行Eclipse-CDT会导致java.lang.ClassNotFoundException - Running Eclipse-CDT on Ubuntu 18.04 causes java.lang.ClassNotFoundException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM