gcc does not find files that are on the search path - linux

I'm using software on Linux Ubuntu 14.04 64bit that uses gcc. I get errors about files or programs not being found like these:
cc: error trying to exec 'cc1': execvp: No such file or directory
or
fatal error: stddef.h: No such file or directory
However, when I do
gcc -print-search-dirs
I get many paths, and cc1 is on the first path in that list (/usr/lib/gcc/x86_64-linux-gnu/4.8/). I do not understand this.
Then I created a link to cc1 as follows (in /usr/bin):
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1 cc1
Now the first error disappears, but I get the second error. Strange again, because I have this file /usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h which is again on the gcc search path.`
I'm not an expert in gcc at all, but this makes no sense to me. Thanks for your help.

Related

GNU Prolog (glpc): error trying to execute as: No such file or directory

I'm trying to use the GNU Prolog Compiler to build an executable from my Prolog program like so:
$ gplc solution.prolog -o prog
and it's failing with a really cryptic error:
error trying to execute as: No such file or directory
I can't figure out what it's trying to tell me is missing. Does anyone know?
I'm using Fedora Silverblue 37, and glpc is running inside of a 'toolbox' that is also Fedora 37.
The issue appears to have been that I didn't have a C compiler installed. I installed the gcc package, and got a different error:
gcc: fatal error: cannot read spec file ‘/usr/lib/rpm/redhat/redhat-hardened-ld’: No such file or directory
Apparently to get that file, I needed to install the redhat-rpm-config package. I found that package name from this relevant comment on the RedHat bugzilla.
Compilation succeeds now!

Ubuntu 20.04 croscompile using yocto jethro invalid gcc search paths

I have been trying to cross-compile using toolchain from yocto-jethro BSP with the following error:
x86_64-poky-linux-gcc: error trying to exec 'cc1': execvp: No such file or directory
I can see that the search directories have been truncated.
x86_64-poky-linux-gcc --print-search-dirs returns:
# /mnt/data/Projects/tmr2-sdk/sdk/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-gcc --print-search-dirs
install: oots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/5.2.0/
programs: =oots/x86_64-pokysdk-linux/usr/libexec/x86_64-poky-linux/gcc/x86_64-poky-linux/5.2.0/:oots/x86_64-pokysdk-linux/usr/libexec/x86_64-poky-linux/gcc/x86_64-poky-linux/5.2.0/:oots/x86_64-pokysdk-linux/usr/libexec/x86_64-poky-linux/gcc/x86_64-poky-linux/:oots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/5.2.0/:oots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/:oots/x86_64-pokysdk-linux/usr/x86_64-poky-linux/bin/x86_64-poky-linux/5.2.0/:oots/x86_64-pokysdk-linux/usr/x86_64-poky-linux/bin/
libraries: =oots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/5.2.0/:oots/x86_64-pokysdk-linux/usr/x86_64-poky-linux/lib/../lib/x86_64-poky-linux/5.2.0/:oots/x86_64-pokysdk-linux/usr/x86_64-poky-linux/lib/x86_64-poky-linux/5.2.0/:oots/x86_64-pokysdk-linux/usr/x86_64-poky-linux/lib/../lib/:/not/exist/lib/../lib/x86_64-poky-linux/5.2.0/:/not/exist/lib/x86_64-poky-linux/5.2.0/:/not/exist/lib/../lib/:/not/exist/usr/lib/../lib/x86_64-poky-linux/5.2.0/:/not/exist/usr/lib/x86_64-poky-linux/5.2.0/:/not/exist/usr/lib/../lib/:oots/x86_64-pokysdk-linux/usr/x86_64-poky-linux/lib/:/not/exist/lib/:/not/exist/usr/lib/
Directories should start with:
/mnt/data/Projects/tmr2-sdk/sdk/sysroots/
instead they start with:
oots
I get the same result when I source the environment-setup-target from yocto BSP or execute compiler directly.
Cross-compilation was working on ubuntu 18. Similar BSP created in yocto-sumo works on ubuntu 20.04
When I add --sysroots to GCC it effects only the libraries search dirs.
Does anyone have a clue on how can I resolve the issue or where to look to find the problem?
Where does the gcc take the search-dirs? I can see that sourcing environment-setup-target does not effect the compiler search-dirs.
Thanks for any hints
Fixed in later issues by commit:
https://git.yoctoproject.org/cgit.cgi/poky/commit/scripts/relocate_sdk.py?id=c3c793b4286367b7050c8ec92fb90a1a9f85a89a

fatal error: pthread.h: No such file or directory

I'm using macbook and terminal compiling gcc version 4.8.1. I solve some problem like:
fatal error ~~~~ No such file or directory
by adding such files in compile path myself. As far, those error was resolved by finding in finder application and add in root directory /usr/local/include/c++/4.8.1 myself.
But pthread.h does not exist at all my computer.
How can I get that header file?
Use this command:
gcc -I/usr/local/include/c++/4.8.1/... myfile.c -o myfile
-I indicate gcc to take include file from this specified path.

Undefined reference under WinMain#16 in cygwin

i am new to stackflow and i previously i have no background in computer system and programming. However, now i need to run analysis under cygwin for my bioinformatics project. I encounter some error when i try to compile a file name 'zone_b.linux'using cygwin, to produce an executable program. The linux file is download from web https://github.com/haddocking/HADDOCK-binding-sites-tutorial/blob/master/ana_scripts/zone_b.linux. When i try to compile using the following command under cygwin it produce the following error:
$ gcc zone_b.linux
/usr/lib/gcc/i686-pc-cygwin/6.4.0/../../../libcygwin.a(libcmain.o): In
function `main':
/usr/src/debug/cygwin-2.9.0-3/winsup/cygwin/lib/libcmain.c:37: undefined
reference to `WinMain#16'
collect2: error: ld returned 1 exit status
Error description
I search the following error under stackoverflow, and i found two post with similar problem.
First is the post from undefined reference to `WinMain#16'. It stated that the problem is due the Microsoft'linker uses a runtime library entry point(winMainCRTStartup) that calls Microsoft's non-standard WinMain instead of standard main. So, i try the post's suggestion of including the entry by following command
$ gcc zone_b.linux /entry:winMainCRTStartup
gcc: error: /entry:winMainCRTStartup: No such file or directory
However i get the error no such file or directory. I think maybe it is because i am running under cygwin not mingW.
Second post is the Undefined reference to WinMain in Cygwin. From the post, it said use -c compile flag to only produce object file. However, for my case, i am not using any -c. Therefore, i think it is not relevant to my issue.
I would appreciate if anyone could kindly explain to me since i am new to this computing area. Thank you.
zone_b.linux is the compiled and linked executable program to run on a linux machine. It is a 32-bit ELF binary file. It will not work on a Windows machine, even using cygwin or mingw32, without re-compulation.
You probably have to compile zone_b.f, a FORTRAN source file, using the gfortran compiler to create a zone_b.exe that is usable in cygwin. I saw no instructions for this, but try something like gcc zone_b.f and cross fingers. Be sure gfortran is installed using cygwin setup.
You will also need to (re-)build the other executables (cluster_struc and contact) by performing make in the ana_scripts directory. Any supplied executables (from the git clone ... or a downloaded .zip file) will not work under cygwin.
You will need to have perl and python installed. I think perl is installed by default. You can install python2 using cygwin setup. The python script looked like it will work with python2 or python3, whichever is the default. On cygwin, today, python2 is the default python. I don't do perl, so cross your fingers.

arm-linux-gnueabi-gcc compiled binary not executing on ARM

I am trying to compile a Hello World for ARM-1136J-S processor. When I compile the C source using CodeSourcery arm-none-linux-gnueabi-gcc (2008q3 edition), it executes successfully on the ARM, but when I compile same code using arm-linux-gnueabi-gcc (installed through apt-get in Ubuntu 12.01) it gives the following error:
./helloworld: line 1: syntax error: unexpected word (expecting ")")
readelf of both the executables show that the binary compiled using Ubuntu toolchain has following extra attributes:
Tag_CPU_unaligned_access: v6
Tag_DIV_use: Not allowed
How can I make it run using Ubuntu toolchain? Can anyone give some hint on that? Thanks
./helloworld: line 1: syntax error: unexpected word (expecting ")")
This doesn't look like a native code error at all - it looks like a script error. Are you sure "helloworld" is actually your compiled binary. Running compiled C code binaries does not give syntax errors ...
Check that your kernel has support for THUMB binaries:
zcat /proc/config.gz |grep THUMB
Try running 'readelf' on your executable. If the entry point address is an odd number (indicating THUMB or mixed ARM/Thumb) and your kernel lacks THUMB executable support, your binary will be rejected by the kernel, and will be attempted to be run as a shell script.
I had the same problem. The problem went away by adding "-static" to link:
arm-linux-gnueabi-gcc -c test.c -o test.o
arm-linux-gnueabi-g++ -o test test.o -static
If your code use "gethostbyname" you will get
warning: Using 'gethostbyname' in statically linked..
but that is another subject and not easily solved.

Resources