Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Hello World Compiling issue(Example works, mine doesn't)
Hello World Compiling issue [message #1786250] Fri, 27 April 2018 15:50 Go to next message
Dante Nahuel is currently offline Dante NahuelFriend
Messages: 1
Registered: April 2018
Junior Member
Hi all
I installed Eclipse C/C++ on Ubuntu 16.04

When I create a new project and try to compile a Hello World, it gives me the following errors on the Console:

(-text+0x20): undefined reference to 'main'
collect2: error: ld returned 1 exit status
make: *** [test1] Error 1


This is the code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
     puts("Hello World");
     return EXIT_SUCCESS;
}


However, the strange part is that when creating a project, if I select the project type as Hello World ANSI C Project, the project compiles...

Projects have the same code and the same structure, with the same Includes folders and the same src folder with the .c file in them....
I have no idea what's going on.
Could you help me?
Re: Hello World Compiling issue [message #1786323 is a reply to message #1786250] Mon, 30 April 2018 23:47 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
They probably DON'T have the same structure or selected options.
Rather than spending a lot of time investigating why,
simply use the HelloWorld project as a template.

1) File --> New --> C Project --> Executable --> Hello World C Project
2) Give it another name and pick a location for it
3) Select a tool chain
4) Press FInish
5) delete or modify <project path>/src/<project name>.c
6) add your own code to <project path>/src

If you are really interested, compare the project files (.project, .cproject, etc.) between the two projects to find what's different.

[Updated on: Tue, 01 May 2018 16:58]

Report message to a moderator

Previous Topic:C++14 and C++17 support
Next Topic:Align Const, deleting code
Goto Forum:
  


Current Time: Thu Jan 23 08:31:04 GMT 2025

Powered by FUDForum. Page generated in 0.03413 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top