GCC compiler errors with “No such file or directory” - c

My Ubuntu version is 14.04 LTS. I have a C program copied on the desktop by the name sendRawEth.c. When I write:
gcc sendRawEth.c -o sendRawEth
The compiler complains:
gcc: error: sendRawEth.c: No such file or directory
gcc: fatal error: no input files
I have no idea how to solve this error.

please do the following.
On terminal check the present directory by 'pwd' command and then check the directory in which your programme is there and see if they are same or not. And while writing gcc yourfile it's case sensitive. Hope this helps

There are 2 reasons for such errors.
You said you copied your C programs in your desktop folder.
This means you may have only copied sendRawEth.c. file format not the executable file.
You should ensure you copy the .exe files as well.
You need to change the directory to the same folder that you copied your programs into.
First, check your current folder by typing pwd.
Then change it to your required folder with:
cd /outerfolder/your program folder
Then compile it with:
gcc -o programname programname.c
And finally execute it with:
./programname

Related

Cannot get gcov to produce any coverage data

Failing to get gcov coverage file with my C/C++ Makefile project with googletest on Windows with mingw32
Full source code at https://github.com/rusefi/rusefi/tree/gcov/unit_tests
I have
USE_OPT += -fprofile-arcs -ftest-coverage
ULIBS += -lgcov --coverage```
and I get .gcno files next to my .o files in build\obj folder
I execute rusefi_test.exe and I see no new files with coverage data :(
nm rusefi_test.exe
confirms that gcov is inside my binary
I've already added explicit flush at the end
extern "C" void __gcov_flush();
__gcov_flush();
but I still do not see any
90.00% of 10 source lines executed in file tmp.c
style line at the end of stdout
I've tried copying my .exe from build to build\obj folder but this did not improve anything.
It looks like my compiler has something to do with this! I've moved to a simple HelloWorld.cpp application and depending on compiler I either get runtime file or not!
main.exe produced by "g++" from cygwin produces the runtime file while x86_64-w64-mingw32-g++ from cygwin does NOT produce main.gcda file!
x86_64-w64-mingw32-g++ bundled with cygwin seems to be affected while same x86_64-w64-mingw32-g++ downloaded directly from mingw64 seems to work.
There is https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=854368 which they say is closed but at least tells me that sometimes it's about the compiler itself :(

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!

C program, calling object file

I have written a simple helloworld.c program. I can compile it and run it on linux terminal using gcc and ./a.out command. My query is regarding calling .o file without any extension. For example, to run my program instead of typing "./helloworld.out", I want to run it using keyword "helloworld" on my terminal. Any hints???
Thank You.
Just compile using
gcc -o helloworld helloworld.c
The -o option is for the output file name
Then use:
./helloworld
You need the ./ to tell the shell where the executable resides, since the current directory is unlikely to be in $PATH.

How do I not type the full path to gcc and the MacOSX sdk in terminal?

In terminal every time I want to compile a C file I have to type out the full path to both the gcc alias and the MacOSX SDK. For example, to run a main.c fine I would type
$ cd /Users/Will/Desktop/C
$ /Users/Will/Desktop/C/gcc -isysroot /Developer/SDKs/MacOSX10.6.sdk main.c
However, my directory is in the Desktop/C folder so I should not have to type the full path, yet when I type
$ cd /Users/Will/Desktop/C
$ gcc main.c
I get
-bash: gcc: command not found
Furthermore, it seems that it should already know to look in /Developer/SDKs/MacOSX10.6.sdk for header files such as stdio.h, yet when I type
$ /Users/Will/Desktop/C/gcc main.c
I get something like
main.c:1:19: error: stdio.h: No such file or directory
How do I fix this?
If it's in your current working directory, use ./gcc.
Otherwise, point your $PATH to that directory, and you'll be able to use it from anywhere as gcc.
As for not having to type out the SDK path each time, you could write a simple bash script and place it in your $HOME/bin (assuming you've already added gcc to your $PATH, otherwise add the full path)...
#!/bin/sh
gcc -isysroot /Developer/SDKs/MacOSX10.6.sdk "$#"
Make sure to give it execute permissions with chmod +x gcc_wrapper. Then you should be able to use it from anywhere, and any arguments passed to it wil be tacked on the end.
in unix systems
open the file .bashrc in your home folder
add an alias in that file
eg :
alias mygcc="/Users/Will/Desktop/C/gcc"
close the terminal and reopen it, now onwards u can use mygcc filename.c for compiling
likewise you can add an alias to mac sdk too .
Refer this link

Still get 'curl/curl.h: No such file or directory' in spite of all looks proper

I installed on windows curl 7.28.0 from curl-7.28.1-devel-mingw32.zip through minGW console to default directory like:
./config && make && make install
All needed headers (aka curl.h, types.h ...) I see in C:\MinGW\msys\1.0\local\include\curl
libcurl.pc placed in C:\MinGW\msys\1.0\local\lib\pkgconfig\
libcurl.a, libcurl.dll.a and libcurl.la placed in C:\MinGW\msys\1.0\local\lib.
My download_file.c file includes are:
...
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
...
I try to compile the C code with followed command through gcc:
$ gcc -IC:/MinGW/msys/1.0/include/
-IC:/MinGW/msys/1.0/local/include/curl
-IC:/MinGW/msys/1.0/local/lib/pkgconfig
-o download_file download_file.c -llibcurl -lcurl
with absolute path get the same error:
gcc -I/include/
-I/local/include/curl
-I/local/lib/pkgconfig
-o download_file download_file.c -llibcurl -lcurl
But I still get an error:
download_file.c:21:23: fatal error: curl/curl.h: No such file or directory compilation terminated.
row 21 is #include <curl/curl.h>
What I did wrong? Please help.
You have the curl/ directory in the source code, but also in the option.
It seems the option should point out the higher-level directory in which curl/ is, so it should be something like:
-I/local/include/
I think the problem is likely that you give your include paths on the command line in the Win32 path format. This is not the same as the one used by msys (or ultimately Cygwin).
Try these:
$ gcc -I/include/
-I/local/include/curl
-I/local/lib/pkgconfig
...
Hope I got the absolut paths right, but you can check in your msys shell.
What ticked me off was that you use ./config, which wouldn't work from the Command Prompt, but works from the msys shell. So you need to give paths that all the programs in MinGW understand.
Basically, most programs in MinGW only have the concept of a single file system root, like on any unixoid system, while Win32 has multiple (the drive letters). Since the MinGW programs are linked accordingly, you need to give paths that they understand.
Thank you very much to #0xC0000022L and #unwind. By your help I fixed my problem.
0xC0000022L you are right about absolute path
unwind you are right about -I/local/include/ instead -I/local/include/curl
I found other problem: -L/local/lib instead -I/local/lib.
So this is a working command:
gcc -I/include/
-I/local/include
-L/local/lib
-o download_file download_file.c -llibcurl -lcurl

Resources