Linking ‘newlib’ and ‘libgloss’ directories from newlib source inside gcc source directory worked fine! Thanks! Alex From: Kai Ruottu <kai.ruottu@xxxxxxxxxxx> Sent: Wednesday, January 22, 2020 7:00 PM To: Alex Rocha Prado <alex.prado@xxxxxxx> Subject: [EXT] Fwd: Re: g++ for riscv32 "bare metal" Caution: EXT Email -------- Välitetty viesti / Fwd.Msg -------- Aihe: Re: g++ for riscv32 "bare metal" Päiväys: Wed, 22 Jan 2020 23:57:34 +0200 Lähettäjä: Kai Ruottu <kai.ruottu@xxxxxxxxxxx><mailto:kai.ruottu@xxxxxxxxxxx> Vastaanottaja: gcc-help@xxxxxxxxxxx<mailto:gcc-help@xxxxxxxxxxx> Alex Rocha Prado kirjoitti 22.1.2020 klo 22.51: Hi All, First of all, I am not sure if "bare metal" is correct. My goal is to compile g++ to run on Linux and compile code for rv32emc bare metal (no operating system). I could get gcc and binutils compiled without any kind of libc like newlib performing the below steps: 1) Configure, compile and install binutils 2) Configure, compile and install gcc (WORKS FINE) Based on what I saw on the internet, to compile g++ it is mandatory to perform the following steps: 1) Configure, compile and install binutils 2) Configure, compile and install gcc 3) Configure, compile and install newlib 4) Reconfigure, recompile and reinstall gcc/g++ using --with-newlib option in configure (DO NOT WORK) The phases 3 and 4 should be vain. Usually people just symlink the 'newlib' and 'libgloss' subdirs from the newlib-x.y.z sources to the GCC main source directory, use '--with-newlib' in GCC configure (and '--enable-languages=c,c++' of course) and be happy. The newlib sources include the required standard C headers (for the target) and they will be found there during the GCC build. The big question then is whether the newlib sources support an embedded riscv32 target at all. If not, your phase 3 should have failed too. If it didn't fail, you didn't understand something simple at all : As default the installed newlib is searched in '$prefix/$target/...' where the values are those you give in '--prefix=$prefix' and '--target=$target' when configuring the GCC sources. If the installed newlib for the target isn't in 'include' and 'lib' there, it cannot be found. Very simple... The step (4) generate an error during compile phase. What error?