For my projects I have to customize the openssh code and I am planning to build the openssh-portable(https://github.com/openssh/openssh-portable) source code in the Alpine linux. But I am getting the following error while doing so.

*/home/openssh-portable # make
(cd openbsd-compat && make)
make[1]: Entering directory '/home/openssh-portable/openbsd-compat'
cc -g -O2 -pipe -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -fstack-protector-strong -fPIE   -I. -I.. -I. -I./..  -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -DHAVE_CONFIG_H -c arc4random.c
In file included from /usr/include/fortify/sys/socket.h:25,
                 from ../includes.h:27,
                 from arc4random.c:27:
**/usr/include/fortify/stdlib.h:40:1: error: 'realpath' undeclared here (not in a function); did you mean 'realloc'?**
_FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
/usr/include/fortify/stdlib.h:41: confused by earlier errors, bailing out
make[1]: *** [Makefile:99: arc4random.o] Error 1
make[1]: Leaving directory '/home/openssh-portable/openbsd-compat'
make: *** [Makefile:165: openbsd-compat/libopenbsd-compat.a] Error 2*

I suspect it is because the Alpine linux comes with the musl c librray rather than glibc library.

I would like to know how to solve this error.

  • Is it possible to install glibc in Alpine and configure the make command to use the glibc rather than musl c lib?
  • Or should I cross compile the openssh-portable using musl C libarary? if so any guidance or steps will be appreciated?
  • or is there any Alpine(i.e, musl C lib) compatible source code available which I can pull from a repo

As specified in the environment, I am able to run autoreconf, ./configure and make commands successfully.

1 Answer 1


The issue seems to be with the fortify headers.

I am able to build openssh-portable successfully on Alpine 3.8 without issues:

  • Fresh alpine:3.8 image
  • Installed build prerequisites: apk add autoconf gcc make musl-dev openssl-dev zlib-dev
  • autoreconf && ./configure && make -j8

However, installing fortify-headers and reconfiguring causes the build to break with the above. Fortify has its own stdlib.h which makes use of __orig_realpath, which I suspect is a GNU extention.

If fortify headers are not a strong requirement for your openssh build, try to omit them (apk del fortify-headers) and repeat the build.

  • Thanks a lot valiano. This really solved my problem. Since I am a newbie to Linux development, so did not realise I could delete the fortify headers. Commented May 15, 2019 at 11:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .