BSplitter
BSplitter

Reputation: 117

Trying to use Eclipse for c++ project on Mac

I am a total noob at programming and IDEs. I am attempting to open a project for some research that I am doing. I have a Macbook Pro using Mac OS High Sierra 10.13.6.

The project that I'm trying to open is a c++ project, but every time I open it, there are error messages everywhere. It appears that the header files aren't even being recognized. A screenshot is linked below. From what I've read so far, the issue seems to be that I don't have a proper debugger for c++. I downloaded XCode after I downloaded Eclipse like some guides have recommended, but it still hasn't fixed the issue.

Other sources I've found on this site use highly technical language (Eclipse GDB MacOSX Mavericks), so I'm struggling to figure out how to fix the problem. If anyone has any ideas, I'd love to hear them.

Error Message

Upvotes: 1

Views: 844

Answers (2)

OrenIshShalom
OrenIshShalom

Reputation: 7172

Here is a better solution for beginners. Create a file called HelloWorld.cpp and copy paste the following inside:

#include <stdio.h>
int main(int argc, char **argv)
{
    printf("Hello world\n");
    return 0;
}

Then open your terminal ( like that ) and write this:

$ g++ -g -o main HelloWorld.cpp

If this goes smooth it means you have gcc installed (good!). After that try to run this:

$ gdb ./main

If this goes smooth it means you have gdb installed (great!). Move to create a new Eclipse project with this file only and update your post if there are any problems. If this goes smooth gradually migrate your stuff to HelloWorld.cpp. If gcc or gdb steps above fail, you have to install them first. There are many online guides on how to do that. Good luck!

Upvotes: 1

Bayleef
Bayleef

Reputation: 195

I am by no means a Mac expert or do I know much about eclipse CDT or Xcode but I can offer what I know. This is not a complete answer but I just want to share as I also know what it is like to struggle with C code on OSX.

First, You need to make sure the C/C++ compilers are installed on the Mac properly. They come with XCode and I believe the compiler is Clang. Then you need to make sure the standard libs were installed correctly. That whole issue is your first problem and should be asked to an XCode programmer and what not.

Second, to use eclipse CDT you need to tell it where and what compiler you are using. As well as the linked and debugger. You can do this in the project properties or settings. The stuff should usually be put in the path variable but once eclipse CDR knows where to find all that and everything is installed correctly it should pick up the header files and then include them in every project!

That’s all I can really provide you and I hope you can find out more.

Upvotes: 0

Related Questions