我正在尝试在HP-UX B.11.31 U ia64上构建共享libz.so。遇到以下2个命令时出现问题。我在这里发布命令和configure.log ......................................... .................................................. ...............................
bash-4.3$ CFLAGS=-"z +DD64 -mt" ./configure -s
Checking for gcc...
Compiler error reporting is too harsh for ./configure (perhaps remove -Werror).
** ./configure aborting.
bash-4.3$ cat configure.log
--------------------
./configure -s
Mon Nov 20 06:01:38 PST 2017
Checking for gcc...
=== ztest25909.c ===
extern int getchar();
int hello() {return getchar();}
===
gcc -c ztest25909.c
... using gcc
Checking for obsessive-compulsive compiler options...
=== ztest25909.c ===
int foo() { return 0; }
===
gcc -c -z +DD64 -mt ztest25909.c
cc1: error: unrecognized command line option "-mt"
(exit code 1)
Compiler error reporting is too harsh for ./configure (perhaps remove -Werror).
** ./configure aborting.
--------------------
bash-4.3$ CFLAGS="-z +DD64 -pthread " ./configure -s
Checking for gcc...
Checking for shared library support...
No shared library support; try without defining CC and CFLAGS
Building static library libz.a version 1.2.11 with gcc.
Checking for size_t... Yes.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for strerror... No.
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... No.
WARNING: vsnprintf() not found, falling back to vsprintf(). zlib
can build but will be open to possible buffer-overflow security
vulnerabilities.
Checking for return value of vsprintf()... Yes.
Checking for attribute(visibility) support... Yes.
bash-4.3$ cat configure.log
--------------------
./configure -s
Mon Nov 20 06:04:13 PST 2017
Checking for gcc...
=== ztest26045.c ===
extern int getchar();
int hello() {return getchar();}
===
gcc -c ztest26045.c
... using gcc
Checking for obsessive-compulsive compiler options...
=== ztest26045.c ===
int foo() { return 0; }
===
gcc -c -z +DD64 -pthread ztest26045.c
Checking for shared library support...
=== ztest26045.c ===
extern int getchar();
int hello() {return getchar();}
===
gcc -w -c -z +DD64 -pthread -fPIC ztest26045.c
gcc -shared -z +DD64 -pthread -fPIC -z +DD64 -pthread -fPIC -o ztest26045.so ztest26045.o
ld: Unrecognized argument: +DD64
Fatal error.
collect2: ld returned 1 exit status
(exit code 1)
No shared library support; try without defining CC and CFLAGS
Building static library libz.a version 1.2.11 with gcc.
=== ztest26045.c ===
#include <stdio.h>
#include <stdlib.h>
size_t dummy = 0;
===
gcc -c -z +DD64 -pthread ztest26045.c
Checking for size_t... Yes.
=== ztest26045.c ===
#include <sys/types.h>
off64_t dummy = 0;
===
gcc -c -z +DD64 -pthread -D_LARGEFILE64_SOURCE=1 ztest26045.c
Checking for off64_t... Yes.
Checking for fseeko... Yes.
=== ztest26045.c ===
#include <string.h>
#include <errno.h>
int main() { return strlen(strerror(errno)); }
===
gcc -z +DD64 -pthread -D_LARGEFILE64_SOURCE=1 -o ztest26045 ztest26045.c
ld: Unrecognized argument: +DD64
Fatal error.
collect2: ld returned 1 exit status
(exit code 1)
Checking for strerror... No.
=== ztest26045.c ===
#include <unistd.h>
int main() { return 0; }
===
gcc -c -z +DD64 -pthread -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR ztest26045.c
Checking for unistd.h... Yes.
=== ztest26045.c ===
#include <stdarg.h>
int main() { return 0; }
===
gcc -c -z +DD64 -pthread -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR ztest26045.c
Checking for stdarg.h... Yes.
=== ztest26045.c ===
#include <stdio.h>
#include <stdarg.h>
#include "zconf.h"
int main()
{
#ifndef STDC
choke me
#endif
return 0;
}
===
gcc -c -z +DD64 -pthread -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR ztest26045.c
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
=== ztest26045.c ===
#include <stdio.h>
#include <stdarg.h>
int mytest(const char *fmt, ...)
{
char buf[20];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
return 0;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
===
gcc -z +DD64 -pthread -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR -o ztest26045 ztest26045.c
ld: Unrecognized argument: +DD64
Fatal error.
collect2: ld returned 1 exit status
(exit code 1)
Checking for vsnprintf() in stdio.h... No.
WARNING: vsnprintf() not found, falling back to vsprintf(). zlib
can build but will be open to possible buffer-overflow security
vulnerabilities.
=== ztest26045.c ===
#include <stdio.h>
#include <stdarg.h>
int mytest(const char *fmt, ...)
{
int n;
char buf[20];
va_list ap;
va_start(ap, fmt);
n = vsprintf(buf, fmt, ap);
va_end(ap);
return n;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
===
gcc -c -z +DD64 -pthread -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR -DNO_vsnprintf ztest26045.c
Checking for return value of vsprintf()... Yes.
=== ztest26045.c ===
#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
int ZLIB_INTERNAL foo;
int main()
{
return 0;
}
===
gcc -c -z +DD64 -pthread -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR -DNO_vsnprintf ztest26045.c
Checking for attribute(visibility) support... Yes.
ALL = static all64
AR = ar
ARFLAGS = rc
CC = gcc
CFLAGS = -z +DD64 -pthread -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR -DNO_vsnprintf -DHAVE_HIDDEN
CPP = gcc -E
EXE =
LDCONFIG = ldconfig
LDFLAGS =
LDSHARED = gcc
LDSHAREDLIBC = -lc
OBJC = $(OBJZ) $(OBJG)
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
RANLIB = ranlib
SFLAGS = -z +DD64 -pthread -fPIC -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR -DNO_vsnprintf -DHAVE_HIDDEN
SHAREDLIB =
SHAREDLIBM =
SHAREDLIBV =
STATICLIB = libz.a
TEST = all teststatic test64
VER = 1.2.11
Z_U4 =
SRCDIR =
exec_prefix = ${prefix}
includedir = ${prefix}/include
libdir = ${exec_prefix}/lib
mandir = ${prefix}/share/man
prefix = /usr/local
sharedlibdir = ${libdir}
uname = HP-UX
--------------------
使用./configure -s
,CC设置为gcc并且编译&amp;建立.so。但是1.不是应该选择cc而不是gcc。 2. libz.so:ELF-32共享对象文件 - IA64 - 32位,我想要64位
zlib-1.2.11和zlib-1.2.3之间的行为差异
hpi11efv:$ echo $SHELL
/bin/ksh
hpi11efv:$ CFLAGS="-z +DD64 -mt " ./configure -s
Checking for gcc...
Checking for shared library support...
No shared library support; try without defining CC and CFLAGS
Building static library libz.a version 1.2.11 with cc.
Checking for size_t... Yes.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for strerror... Yes.
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
hpi11efv:$ cd ../zlib-1.2.3
hpi11efv:$ CFLAGS="-z +DD64 -mt " ./configure -s
Checking for gcc...
Checking for shared library support...
Building shared library libz.so.1.2.3 with cc.
Checking for unistd.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for errno.h... Yes.
Checking for mmap support... Yes.
hpi11efv:$ uname -a
HP-UX hpi11efv B.11.31 U ia64