Hello World Compiling issue [message #1786250] |
Fri, 27 April 2018 11:50  |
Eclipse User |
|
|
|
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 19:47  |
Eclipse User |
|
|
|
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 12:58] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03190 seconds