Netbeans errors with C - c

I'm trying to do some basic programs in C in NetBeans, it worked well yesterday but now it shows some errors that I can't get rid off. First one shows when I try to compile my main.c file via NetBeans's terminal. I have included 2 files: stdio.h and stdlib.h. They don't show errors in code (it's not highlighted with red underline), only when I try to compile it via terminal. But when I tried to compile file via windows's cmd, it worked. Second error shows when I run program in NetBeans.
1st error: bash-4.4$ gcc main.c -o nav1 main.c:13:19: fatal error: stdio.h: No such file or directory
2nd error: bash.exe: warning: could not find /tmp, please create!

Related

How to fix error from structmember.h when compiling with g++

I made a python script that I wanted to compile to an executable. I used cython first, to create a .c file and then I wanted to compile that to an executable with g++. This however causes an error stating that something in structmember.h (which is a header file that comes with python) is apparently wrong.
I have tried to find other people with the same problem, but I couldn't.
I used this to compile:
g++ Training_set.c -o Training_set.exe
The error i got was:
Training_set.c:17362:26: fatal error: structmember.h: No such file or directory
compilation terminated.
structmember.h:21:5 error: 'Py_ssize_t" does not name a type
structmember.h:67:11 error: expected constructor, destructor or type conversion before '(' token
structmember.h:68:17 error: expected constructor, destructor or type conversion before 'Pymember_SetOne'
So i managed to fix my problem, somehow if I put all header files in a subdirectory and provide the path to them with -I it does work.

Compiling c program with dependencies, h and h0 files

I am trying to compile the gjh solver - written in C - into an executable file in windows. It is available on netlib
I downloaded the c file and am using gcc compiler via WinGW on windows' command prompt. Trying to compile the gjh.c file directly gave me an error that says:
gjh.c:33:21: fatal error: getstub.h: No such file or directory
#include "getstub.h"
compilation terminated.
I assumed that compiling gjh.c requires the dependency getstub.h.
getstub.h is not the only dependency required, there are other dependencies, namely: arith.h, asl.h, funcadd.h, and stdio1.h. All of these files are available on the same link where I found getstub.h. However, arith.h0 and stdio1.h0 are available instead of arith.h and stdio1.h.
Are these files the same? I tried to rename the .h0 files to .h and tried to compile gjh.c, but I got this error:
collect2.exe: error: ld returned 1 exit status
Are the two files the same? If not, is there any way for me to compile the gjh solver successfully into an .exe?
If that's the only problem in compiling, try using the -I switch in gcc:
gcc -I/my/path/to/include/files -o gjh gjh.c
the -I switch hints to gcc where to find your #include files.
I am not sure about the stdio1.h. I think your approach to rename is OK but that reference to external functions such as Sprintf. You need to link with a library defining that. If you know where it comes from, use the -L and -l switch in gcc for that:
gcc -I/my/path/to/include/files -L/my/path/to/library -lnameoflibrary \
-o gjh gjh.c

Compile error in c files

I have a c file inside "examples" folder inside ArtoolKIt that I want to compile in Ubuntu.
Artoolkit works perfectly, but how can I compile this c file from terminal?
I try ./helloWorld but it gives me this error:
No such file or directory
Is there any specific way to compile Artoolkit programs cause I don't see it in its docuemntation.
Use either gcc or clang to compile .c files:
gcc -o hello ./examples/filename.c
the parameter following the -o flag names the file that will be produced by the operation, a parameter without any flag named the source input file.
So, the problem that I had was with my directories! For this wo work you should have inside teh folder Examples of ArtoolKit the thiungs: a folder with data, your c file to be compiled and teh makefile in case you have it so youy can compile with $make command.
Now It works for me!

Fatal Error Message during Compiling

Trying to compile a c file that has the header:
#include <sys/wait.h>
I'm using Cygwin to compile it and it keeps giving me this error whenever I type in gcc minishell.c -o minishell:
minishell.c:4:22: fatal error: sys/wait.h: No such file or directory compilation terminated.
Any clue what the heck is going on?
That's because compiler, in this case, does not know how to reach/find sys/wait.h file so that it can include this file in compilation process. To check which all places compiler will try to find the files, refer:
How to tell C++ library path in Cygwin and MinGW
Above post/link also tells about include paths.

Eclipse fails to compile C project when using a flags

I'm trying to compile a C project with Eclipse, under Ubuntu 12.10 using GCC.
When I use these flags:
http://i.stack.imgur.com/FTxkG.jpg
http://i.stack.imgur.com/MVA2k.jpg
eclipse fails to compile.
The compilation error is the following:
error: ISO C forbids an empty translation unit [-pedantic]
make: *** [.metadata/.plugins/org.eclipse.cdt.make.core/specs.o] Error 1
Why do these problems appear,
and how should I compile with eclipse with the checked flags?
When trying to compile manually from the Terminal with these flags, it compiles successfully. thanks!
Your C project has an empty source file.
You can either:
1) Remove that file. If it is empty why do you need it?
2) Be more relax with your compilation flags, with -pedantic instead of -pedantic-errors for example
3) Add some dumb code to make gcc believe the file is not empty, for example add #include <stdio.h>.

Resources