During attempts to build curl 7.63.0 (and earlier), to resolve known vulnerabilities, difficulty was encountered with libssh2 releases above 1.2.4 as follows:
$ CFLAGS="-static" ./configure \ --with-libssl-prefix=/usr/local \ --prefix=/csdi/src/sco507/root/usr/local ... version: 1.8.0 Host type: i686-pc-sco3.2v5.0.7 Install prefix: /csdi/src/sco507/root/usr/local Compiler: gcc Compiler flags: -static -D_XOPEN_SOURCE_EXTENDED Library types: Shared=yes, Static=yes Crypto library: OpenSSL (AES-CTR: no) Clear memory: unsupported Debug build: no Build examples: no Path to sshd: /etc/sshd (only for self-tests) zlib compression: no $ make Making all in src ... Making all in example make[1]: Entering directory `/csdi/src/sco507/libssh2/libssh2-1.2.4/example' make all-am make[2]: Entering directory `/csdi/src/sco507/libssh2/libssh2-1.2.4/example' source='direct_tcpip.c' object='direct_tcpip.o' libtool=no \ DEPDIR=.deps depmode=gcc /bin/ksh ../depcomp \ gcc -DHAVE_CONFIG_H -I../include -I../example -I/csdi/admin/kevinb/include -static -c direct_tcpip.c direct_tcpip.c: In function `main': direct_tcpip.c:48: `socklen_t' undeclared (first use in this function) direct_tcpip.c:48: (Each undeclared identifier is reported only once direct_tcpip.c:48: for each function it appears in.) direct_tcpip.c:48: parse error before `sinlen' direct_tcpip.c:166: `sinlen' undeclared (first use in this function) make[2]: *** [direct_tcpip.o] Error 1 make[2]: Leaving directory `/csdi/src/sco507/libssh2/libssh2-1.2.4/example' make[1]: *** [all] Error 2 make[1]: Leaving directory `/csdi/src/sco507/libssh2/libssh2-1.2.4/example' make: *** [all-recursive] Error 1 socklen_t is not defined on this host type, but, it is noted that other FOSS projects workaround this limitation. For example, in curl 7.61.0 and above, the file include/curl/system.h works around this with a typedef that kicks in when SCO_DS is not defined: #elif defined(__GNUC__) && !defined(_SCO_DS) ... #else /* generic "safe guess" on old 32 bit style */ # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # define CURL_TYPEOF_CURL_SOCKLEN_T int #endif It could be helpful for the libssh2 project to consider a socklen_t workaround for these systems. The following patch against the 1.8.0 release resolves compilation issues on this platform: $ cat libssh2-1.8.0-i686-pc-sco3.2v5.0.7.patch diff -ru libssh2-1.8.0/include/libssh2.h libssh2-1.8.0-patch1/include/libssh2.h --- libssh2-1.8.0/include/libssh2.h 2016-10-25 01:44:34.000000000 -0500 +++ libssh2-1.8.0-patch1/include/libssh2.h 2019-01-17 14:53:11.000000000 -0600 @@ -114,6 +114,15 @@ # endif /* LIBSSH2_WIN32 */ #endif /* LIBSSH2_API */ +#if (defined(_SCO_DS)) +/* + * socklen_t is not defined in this system, but, it is noted that other FOSS + * projects (i.e. curl include/curl/system.h) define socklen_t in the + * following way to work around build issues: + */ +typedef int socklen_t; +#endif + #ifdef HAVE_SYS_UIO_H # include <sys/uio.h> #endif The aforementioned patch is clearly very specific to the host type, but any equivalent patch that may be more generic is certainly better than the current situation. To build libssh2 on this host type, once the patch is applied, another build issue occurs: $ patch -p1 -i ../libssh2-1.8.0-i686-pc-sco3.2v5.0.7.patch patching file include/libssh2.h $ CFLAGS="-static" ./configure \ --with-libssl-prefix=/usr/local \ --prefix=/csdi/src/sco507/root/usr/local $ make Making all in src make[1]: Entering directory `/csdi/admin/kevinb/src/libssh2/libssh2-1.8.0/src' make all-am make[2]: Entering directory `/csdi/admin/kevinb/src/libssh2/libssh2-1.8.0/src' CC channel.lo In file included from libssh2_priv.h:86, from channel.c:41: /usr/include/sys/uio.h:76: parse error before `off_t' /usr/include/sys/uio.h:76: warning: no semicolon at end of struct or union /usr/include/sys/uio.h:80: parse error before `}' /usr/include/sys/uio.h:80: warning: data definition has no type or storage class In file included from libssh2_priv.h:86, from channel.c:41: /usr/include/sys/uio.h:96: parse error before `readv' /usr/include/sys/uio.h:96: warning: data definition has no type or storage class /usr/include/sys/uio.h:97: parse error before `writev' /usr/include/sys/uio.h:97: warning: data definition has no type or storage class make[2]: *** [channel.lo] Error 1 make[2]: Leaving directory `/csdi/admin/kevinb/src/libssh2/libssh2-1.8.0/src' make[1]: *** [all] Error 2 make[1]: Leaving directory `/csdi/admin/kevinb/src/libssh2/libssh2-1.8.0/src' make: *** [all-recursive] Error 1 off_t is mentioned in the same curl code (include/curl/system.h) where the socklen_t assignment was that helped curl compile. The fix for off_t, however, was not so simple as patching in a typedef as the error actually occurs in a SCO file (/usr/include/sys/uio.h). In /usr/include/sys/uio.h, the problematic off_t assignment only occurs when _XOPEN_SOURCE_EXTENDED is not defined. It is not yet clear how _XOPEN_SOURCE_EXTENDED might get defined properly, but, the libssh2 build error is avoided by manually setting the define: CFLAGS="-D_XOPEN_SOURCE_EXTENDED". Once the off_t problem is resolved, make issues a new error: $ CC= CFLAGS="-static -D_XOPEN_SOURCE_EXTENDED" ./configure \ --with-libssl-prefix=/usr/local \ --prefix=/csdi/src/sco507/root/usr/local $ make ... In file included from /usr/include/sys/termios.h:31, from /usr/include/xpg4v2/termios.h:31, from /usr/include/termios.h:7, from x11.c:23: /usr/include/sys/termio.h:584: `LDNAMEMAX' undeclared here (not in a function) x11.c: In function `main': x11.c:431: `SHUT_RDWR' undeclared (first use in this function) x11.c:431: (Each undeclared identifier is reported only once x11.c:431: for each function it appears in.) make[2]: *** [Makefile:620: x11.o] Error 1 make[2]: Leaving directory '/csdi/src/sco507/libssh2/libssh2-1.8.0/example' make[1]: *** [Makefile:441: all] Error 2 make[1]: Leaving directory '/csdi/src/sco507/libssh2/libssh2-1.8.0/example' make: *** [Makefile:546: all-recursive] Error 1 Note that x11.c is in an "example" directory, so it is simple enough to resolve this issue by disable building the examples: $ ./configure --help | grep example --enable-examples-build Build example applications (this is the default) --disable-examples-build Do not build example applications $ CC= CFLAGS="-static -D_XOPEN_SOURCE_EXTENDED" ./configure \ --with-libssl-prefix=/usr/local --disable-examples-build \ --prefix=/csdi/src/sco507/root/usr/local $ make At this point, the build succeeds with the socklen_t patch being the only source change. If nothing else, and if the patch or an equivalent one is not applied, at least perhaps this post should help anyone else being in such an unfortunate situation as having to build on this host type. (We wanted to build libssh2 to get curl's sftp capability.) Regards, Kevin R. Bulgrien _______________________________________________ libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel