--target=powerpc-eabi: error: static declaration of ‘strndup’ follows non-static declaration

Jonny H via gcc-help gcc-help@gcc.gnu.org
Wed Nov 8 19:23:00 GMT 2017


Dear List, 

I am attempting to build a cross-compiling toolchain for powerpc-eabi (I will also want to build powerpc-elf). I have roughly followed an online tutorial (see [1]). The difference is, I am building gcc 7.2, but other versions of gcc would do. My problem is at the stage of building the full gcc cross-compiler the build stops with the following output:

libtool: compile: /home/rcrozier/build/gcc-powerpc/gcc/./gcc/xgcc -B/home/rcrozier/build/gcc-powerpc/gcc/./gcc/ -B/usr/local/powerpc-eabi/powerpc-eabi/bin/ -B/usr/local/powerpc-eabi/powerpc-eabi/lib/ -isystem /usr/local/powerpc-eabi/powerpc-eabi/include -isystem /usr/local/powerpc-eabi/powerpc-eabi/sys-include -DHAVE_CONFIG_H -I. -I/home/rcrozier/src/gcc/gcc-7.2.0/libgfortran -iquote/home/rcrozier/src/gcc/gcc-7.2.0/libgfortran/io -I/home/rcrozier/src/gcc/gcc-7.2.0/libgfortran/../gcc -I/home/rcrozier/src/gcc/gcc-7.2.0/libgfortran/../gcc/config -I../.././gcc -I/home/rcrozier/src/gcc/gcc-7.2.0/libgfortran/../libgcc -I../libgcc -I/home/rcrozier/src/gcc/gcc-7.2.0/libgfortran/../libbacktrace -I../libbacktrace -I../libbacktrace -std=gnu11 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -Werror=implicit-function-declaration -Werror=vla -fcx-fortran-rules -ffunction-sections -fdata-sections -g -O2 -MT string.lo -MD -MP -MF .deps/string.Tpo -c /home/rcrozier/src/gcc/gcc-7.2.0/libgfortran/runtime/string.c -o string.o
/home/rcrozier/src/gcc/gcc-7.2.0/libgfortran/runtime/string.c:110:1: error: static declaration of ‘strndup’ follows non-static declaration
strndup (const char *s, size_t n)
^~~~~~~
In file included from /usr/local/powerpc-eabi/powerpc-eabi/include/stdio.h:29:0,
from /home/rcrozier/src/gcc/gcc-7.2.0/libgfortran/libgfortran.h:42,
from /home/rcrozier/src/gcc/gcc-7.2.0/libgfortran/runtime/string.c:25:
/usr/local/powerpc-eabi/powerpc-eabi/include/string.h:86:8: note: previous declaration of ‘strndup’ was here
char *_EXFUN(strndup,(const char *, size_t));
^
make[3]: *** [string.lo] Error 1
make[3]: Leaving directory `/home/rcrozier/build/gcc-powerpc/gcc/powerpc-eabi/libgfortran'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/rcrozier/build/gcc-powerpc/gcc/powerpc-eabi/libgfortran'
make[1]: *** [all-target-libgfortran] Error 2
make[1]: Leaving directory `/home/rcrozier/build/gcc-powerpc/gcc'
make: *** [all] Error 2

The error being:

error: static declaration of ‘strndup’ follows non-static declaration


I have configured like this:


configure  --target=$TARGET --prefix=$PREFIX --with-newlib --with-gnu-as --with-gnu-ld --disable-shared --disable-libssp --disable-multilib

where `TARGET` is `powerpc-eabi`, and `PREFIX` is `/usr/local/powerpc-eabi`.

I've found a couple of posts referencing this, e.g. [here][2] but not much. Is there any way I can work around this error? It is related to gfortran, and I really need gfortran.

I got the same error when I then tried to build gcc 6.2 for the powerpc-unknown-elf architecture.

Best regards, 

Richard

[1]: http://www.ifp.illinois.edu/~nakazato/tips/xgcc.html "here"
[2]: http://gcc.1065356.n8.nabble.com/Bug-fortran-66534-New-Compilation-error-of-gfortran-building-on-YDL6-2-td1158727.html "here"



More information about the Gcc-help mailing list