Eclipse error in C project - c

I am new to C programming. I just installed Eclipse CDT and Cygwin. I tried to run this code. But showing 3 errors in problems window of eclipse.
Errors:
1- make:***[CProject.exe]Error 1
2- recipe for target 'Cproject.exe'failed
3- Undefined reference to 'WinMain#16'
Code:
#include<stdio.h>
int main(void)
{
printf("I want to be a competent C programmer");
return 0;
}
I don't know what to do, Can anyone help me?

Set the project type to console application and try again.

Try to compile and execute it with you're command line,
gcc yourfile.c
./a.out
if you don't have gcc, you can install it there : http://www.matpack.de/cygwin/index.html

Related

compiling C program with gcc; Cannot open output file _.exe: no such file or directory

I just started trying to program in C and I've downloaded all kinds of IDE's and compilers and nothing seems to be working. Cygwin keeps giving me this error when i try to compile my program:
C:\Users\Paul\Documents\Timmy
λ gcc -o nutt nutt.c
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld:
cannot open output file nutt.exe: No such file or directory
collect2: error: ld returned 1 exit status.
here is my program
#include <stdio.h>
int main(void) {
printf("y");
return 0;
}
I also want to point out that i have this strange issue when i try to use the "save as" features in notepad or notepad++. when i try to save something this way it will bring up an error message saying the file isn't found and to check the file name and try again. both of these issues seem to have occured around the same time, i'm not sure if they are related. I try saving this way by setting the file type to all types and i just type in "something.c" for the name.
I fixed it! thank you guys for trying to help. I fixed it by turning off controlled folder access in my windows defender security center.
https://answers.microsoft.com/en-us/windows/forum/windows_10-files/cant-save-to-documents-folder-after-fall-creators/b1274473-6dcd-4bbf-8040-6ba1bc79287f
I can now use the save as features and compile my C source files.
I kept trying to google stuff about gcc when it was really window's fault...

"Can not find source" in Eclipse CDT in UBUNTU 14.10

My problem is that I try to debug this simple Hello World Program in Eclipse LUNA CDT and UBUNTU 14.10 but get the error- can't find source at /build/buildd/glibc-2.19/stdio-common/printf.c. My Code is
# include <stdio.h>`
int main()`
{
printf("\n Hello World!!");
return 0;
}
First remove the two ' in your program (first and second line).Before all of this remember to select the " linux gcc " compiler while creating your project file. Then create your source file and give .c extension

Error in linking in C using C-free compiler

I'm using C-Free compiler for c. This was my first program after installation.
I have also installed MinGw.
Here's my program.
#include<stdio.h>
int main()
{
printf("Hello World!");
}
I have this error and I don't know how to solve it.
[Error]\mingw\lib\crt2.o:(.text+0x188):undefined refrence to `__dyn_tls_init_callback`
[Error]\mingw\lib\crt2.o:(.text+0x1c6):undefined refrence to `_setargv`
[Error]collect2:ld returned 1 exit status
Sounds like your installation is corrupted. Check if you have MINGW installed twice.

Code::Blocks 13.12 error - CC1.exe has stopped working

I am using Code::Blocks 13.12 for programming in C. After building and running my simple HelloWorld.c program, it gives an error.
Error: An alert box pop up saying -"cc1.exe has stopped working.A problem caused the program to stop working correctly.Windows will close the program and notify you if a solution is available."
I tried using Notepad++ , the same pop up appears saying a.exe has stopped working.
I am a naive,so have no idea on how to deal with this.
My queries:
1) Am I using an outdated version? If not, how can I get rid of this problem?
2) Which is the most efficient IDE available for C/C++ if Code::Blocks is not that efficient?
My requirement"
-I had been using Turbo C and it doesn't give errors like segmentation fault and other memory related errors that we get in online Compilers or compilers of competitive programming.So, I need an efficient compiler which behaves same as online compilers, so I don't get stuck while solving problems during competitive programming.
This is the simple code giving error:
#include <stdio.h>
void main()
{
printf("Hello world!");
//return 0;
}
Edit:
Even after changing the code to return int, it's giving an error.I tried editing the code as below, but the same window is being popped up again.
int main(void)
{
printf("Hello world!");
return 0;
}
There's no problem with your code, though indeed, as pointed out in the comments, neither void main() nor int main(void) is considered correct, but that's not what's causing the problem. cc1.exe is a MinGW-related file (MinGW is the GCC port for Windows that Code::Blocks uses by default for compilation); if it's crashing, it's possible the installation is corrupt.
I suggest you try reinstalling MinGW - remove Code::Blocks, install the standalone MinGW version, then download Code::Blocks without the compiler suite, install it and configure to use your version of MinGW.
For me, the solution was to choose,
Select target -> Release
from the Build menu. It took lots of time for me to find this!

Build error with a Hello World C program with a default CDT plugin installation in Eclipse on Ubuntu

I just installed the CDT plugin for Eclipse on my Ubuntu machine. I made a new Hello World ANSI C Project and put the code for a basic C program inside the source file:
#include <stdio.h>
int main(void)
{
printf("Hello World\n");
return 0;
}
When I go to build the program, I get the error that "Errors occurred during the build.
Errors running builder 'CDT Builder' on project 'CS47 HW2'.
Illegal character in path at index 4: CS47 HW2"
Furthermore, 2 errors occur when I go to build the program in the Problems window, along with 85 warnings. The two errors are:
Description Resource Path Location Type
./src/CS47 HW2.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC CS47 HW2 C/C++ Problem
and
Description Resource Path Location Type
make: * [libCS47 HW2] Error 1 CS47 HW2 C/C++ Problem
First comment nailed it. For some reason Eclipse would allow a space in the project name with the CDT plugin.

Resources