Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting C++ to compile inside Eclipse

Trying to get Eclipse CDT plugin to compile a simple C++ app. I create a new C++ project, and add 1 file (test.cpp) and code it up like a "Hello, world!" example:

#include <iostream>
using namespace std;

int main()
{
    cout << "Hello, world!";
    return 0;
}

I get highlighted syntax errors on using namespace std and cout, stating (respectively):

Symbol 'std' could not be resolved Symbol 'cout' could not be resolved

I'm sure I didn't install CDT with everything it needed to compile/build a full C++ app. Where could I start looking to figure out what I'm missing?

like image 409
IAmYourFaja Avatar asked Feb 20 '12 21:02

IAmYourFaja


People also ask

How do I run C in eclipse?

Build And Execute Projects In Eclipse For this, right-click the project name on the Project Explorer and click “Run as”. Then select “Local C/C++ Application”. This runs your application.

How do I start a new C project in Eclipse?

Create a new projectGo to Window → Open perspective → Other, select C/C++, and click OK. Go to File → New → C Project, and choose a name for the project (for example, Greeting ). Click Finish to accept all defaults.

How do I set the toolchain path in eclipse?

To create a new managed build project select the File->New->C/C++ Project entry from the File Menu. In the New C/C++ project dialog select “C Managed Build”. Click Next. In this next screen, the project name and location should be set as well as the toolchain.

Can IntelliJ compile C?

C/C++ are not officially supported in IntelliJ IDEA, but you can use CLion. You can browse the JetBrains Marketplace to find an official plugin that adds support for almost any language, framework or technology used today, or for third-party plugins.


1 Answers

Do you have a compiler? Quoting eclipse documentation: 'Eclipse IDE for C/C++ Developers does not contain a compiler or debugger; if your system does not have one, you need to download and install one. Please see the Before you begin section of the C/C++ Development User Guide.'

There you can choose and find out how to install a compiler.

Specifically for your unresolved symbols problem, you need to have correct paths set in Project->Properties->C/C++ General->Paths and Symbols/Includes tab, which depends on the compiler you choose to install.

like image 104
ondrisko Avatar answered Oct 31 '22 17:10

ondrisko