How to solve "cstring: No such file or directory" when compiling gcc from source? - linux

I am trying to compile a gcc from source since I cannot use yum, apt-get and so forth. My steps are simple:
-I download the source GCC (I tried gcc-4.8.4 and gcc-5.3.0) in my pc and I used:
./contrib/download_prerequisites
-After this, I send this my gcc source file to my system using powerPC y Linux.
mkdir objdir
cd objdir
../gcc-4.6.2/configure --prefix=/usr --enable-languages=c,c++,fortran,go
make
I have got the next error:
In file included from ../../gcc-4.9.2/gcc/genmddeps.c:19:0:
../../gcc-4.9.2/gcc/system.h:205:20: fatal error: cstring: No such file or directory
# include <cstring>
^
compilation terminated.
make[3]: *** [build/genmddeps.o] Error 1
make[3]: Leaving directory `/home/root/build/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/home/root/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/root/build'
make: *** [all] Error 2
Any idea about what it is going wrong?
Best regards

Some advice: first, compile (notably for learning purposes) something simpler than GCC, e.g. GNU make if you never compiled GNU stuff from source code.
Then compile a recent GCC (so 5.3 in january 2016) - building issues would be the same with 4.8, and GCC 5 is better! You need the gcc & libc-dev & g++ & libstdc++-dev for your host machine (the one running your future cross-compiler). I am not sure your --prefix=/usr is a good idea. Consider perhaps a --program-suffix=-mine option (otherwise, your system's /usr/bin/gcc could be overwritten, which you don't want to happen)
You could leave the default --prefix=/usr/local and later add appropriately /usr/local/bin/ into your PATH

Related

Kernel module on cross-compile kernel: /bin/sh: 1: scripts/basic/fixdep: Exec format error

I'm doing some experiment on rpi4, and trying to reproduce this kernel module from github https://github.com/sysprog21/dont-trace on my rpi4. I encounter this problem:
make -C /lib/modules/`uname -r`/build M=/home/ubuntu/dont-trace modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.65-rt49-preemptrt-full-raspi'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110
You are using: gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
CC [M] /home/ubuntu/dont-trace/dont_trace.o
/bin/sh: 1: scripts/basic/fixdep: Exec format error
make[2]: *** [scripts/Makefile.build:289: /home/ubuntu/dont-trace/dont_trace.o] Error 126
make[2]: *** Deleting file '/home/ubuntu/dont-trace/dont_trace.o'
make[1]: *** [Makefile:1896: /home/ubuntu/dont-trace] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.65-rt49-preemptrt-full-raspi'
make: *** [Makefile:7: all] Error 2
The kernel here is cross-compiled from x86 server and do show above. I was wondering how to solve this problem & what's the root cause. I can make it on x86 server. It should be something fundamental knowledge I don't understand. Thks!
it seems work this time
My solution might be a bit workaround, but it works. I follow the clues /bin/sh: 1: scripts/basic/fixdep: Exec format error. So I copy the source code to local raspberry pi, and make modules_prepare to construct complete /scripts, then move it into /lib/modules/`uname -r\`/build. It remain the gcc version warning, but work properly.

gcc 4.8.1 will not make

I have a new installation of Ubuntu linux and I am trying to update my gcc complier. The latest gcc compiler depends on gmp, mpfr, and mpc, so I downloaded those and placed the source into the gcc 4.8.1 source folder, as instructed.
configure seems to have run just fine. I did not include any options, because none seemed appropriate. I just ran with the defaults.
When I run make, I get the following error:
configure: error: C++ compiler missing or inoperational
make[2]: \*** [configure-stage1-libcpp] Error 1
make[2]: Leaving directory `/home/clay/programming/C++/gcc-4.8.1'
make[1]: \*** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/clay/programming/C++/gcc-4.8.1'
make: \*** [all] Error 2
I am running out of a terminal window as root, and I did a make distclean and tried a second time, but no dice. I know it can find both gcc and cc because it says so in the make output.
Any ideas?
You need a C++ compiler to build GCC. On Ubuntu, the C++ compiler is in the package g++, separate from gcc (which is a C compiler, not a C++ compiler), so be sure to:
sudo apt-get install g++
first you should ensure a C++ compiler to build on your machine
yum install gcc-c++

Building icu4c fails due to missing findBasename

I try to cross-compiler icu4c 51.1 with Emscripten (clang) via
emconfigure source/configure --host=i386-pc-linux-gnu --prefix=${myprefix} --enable-static --disable-shared --disable-dyload --disable-renaming CXXFLAGS='-DU_USING_ICU_NAMESPACE=0' CPPFLAGS='-DU_DISABLE_RENAMING=1'
emmake make
emmake make install
It compiles most of the sources fine, but fails with
Unpacking ../source/data/in/icudt51l.dat and generating out/tmp/icudata.lst (list of data files)
LD_LIBRARY_PATH=../lib:../stubdata:../tools/ctestfw:$LD_LIBRARY_PATH ../bin/icupkg -d ./out/build/icudt51l --list -x \* ../source/data/in/icudt51l.dat -o out/tmp/icudata.lst
run-detectors: warning: unable to exec /usr/bin/lli-2.8: No such file or directory
run-detectors: warning: unable to exec /usr/bin/lli-2.9: No such file or directory
LLVM ERROR: Program used external function 'findBasename' which could not be resolved!
make[1]: *** [out/tmp/icudata.lst] Error 1
make[1]: Leaving directory `/home/andreas/.emscripten-libs/sources/icu4c/51.1/data'
make: *** [all-recursive] Error 2
So I am wondering, where it tries to find findBasename and what this data compiling is all about.
EDIT:
The error messages come from icupkg being built with clang, which does not make sense in this case. How can I specifc that the libraries are built with clang, but the tools with another compiler?
Sounds like it wasn't able to find, I'm guessing, ICU tool utilities lib in ../lib - might try running ldd or equivalent on icupkg

Unable to compile GCC, but no specific error given

I'm attempting to compile gcc 4.7.1 on Mint Linux with gcc 4.7.2 and get the following output:
[snip]
ar rc .libs/libgmp.a assert.o compat.o errno.o [snip]
rm -fr .libs/libgmp.lax
creating libgmp.la
(cd .libs && rm -f libgmp.la && ln -s ../libgmp.la libgmp.la)
make[5]: Leaving directory `/home/justin/projects/os/linux/src/gcc-4.7.0/build/gmp'
make[4]: Leaving directory `/home/justin/projects/os/linux/src/gcc-4.7.0/build/gmp'
make[3]: Leaving directory `/home/justin/projects/os/linux/src/gcc-4.7.0/build/gmp'
make[2]: Leaving directory `/home/justin/projects/os/linux/src/gcc-4.7.0/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/justin/projects/os/linux/src/gcc-4.7.0/build'
make: *** [all] Error 2
I don't even know where to start looking since I don't get a descriptive error! It looks like it compiles GMP successfully and then fails after that, unable to complete whatever the next step should be.
The question is answered in its comments above. To sum up: The error was due to an improper global (presumably environment) variable, much earlier in the scrollback; that because OP was using a -j flag and other currently active branches did continue building.

Issue trying to build LLVM and clang

I'm trying to build LLVM and clang on my machine (Ubuntu 12.04). I followed the instructions on http://clang.llvm.org/get_started.html up to step 6 (build LLVM and clang). When I make, I get a whole load of warnings about potentially incompatibly plugin versions (to do with dragonegg?). But the whole thing fails with these messages:
llvm[2]: Linking Debug+Asserts executable llvm-tblgen
/usr/bin/ld: /home/peter/llvm/build/Debug+Asserts/bin/llvm-tblgen: hidden symbol `llvm::Type::~Type()' isn't defined
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[2]: *** [/home/peter/llvm/build/Debug+Asserts/bin/llvm-tblgen] Error 1
make[2]: Leaving directory `/home/peter/llvm/build/utils/TableGen'
make[1]: *** [TableGen/.makeall] Error 2
make[1]: Leaving directory `/home/peter/llvm/build/utils'
make: *** [all] Error 1
So any help you could give me would be really helpful.
Thanks
I ended up deleting the llvm folder and checking everything out again, and it worked, so I'm just putting it down to bad timing.
You may want to use the existing LLVM packages, as provided by your distributions.
This askubuntu question about LLVM 3.1 could be relevant.
And you should at least do apt-get build-dep llvm-3.1-dev to ensure all dependencies are available.
You could also ask help on some LLVM related mailing list.

Resources