【问题标题】:gcc, 64 bit, oracle, solarisgcc、64 位、oracle、solaris
【发布时间】:2010-09-13 01:05:30
【问题描述】:
info@s490up # gcc -std=gnu99 -o bla -g -O2 -DSunOS=1 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES= -I/usr/include/libxml2 -I/u/app/oracle/product/11.2/rdbms/demo -I/u/app/oracle/product/11.2/rdbms/public -I/u/app/oracle/product/11.2/rdbms/demo -I/u/app/oracle/product/11.2/rdbms/public blabla.c -lclntsh -lrt -lresolv -lnsl -lsocket -lm -lpthread -liconv -L/usr/lib -R/usr/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl -L/u/app/oracle/product/11.2/lib
ld: fatal: file /u/app/oracle/product/11.2/lib/libclntsh.so: wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to bla
collect2: ld returned 1 exit status

谁能告诉我为什么ld 在这里不能正常工作

(这个长命令取自configure,由于这个错误,它执行不正确)

UPD

file /u/app/oracle/product/11.2/lib/libclntsh.so
/u/app/oracle/product/11.2/lib/libclntsh.so:    ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped

blabla.c

info@s490up # cat /tmp/blabla.c
/* confdefs.h.  */
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define GW_NAME "Kannel"
#define GW_VERSION "1.4.3"
#define VERSION "1.4.3"
#define YYTEXT_POINTER 1
#define _FILE_OFFSET_BITS 64
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define SIZEOF_SHORT 2
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define HAVE_LIBM 1
#define HAVE_LIBSOCKET 1
#define HAVE_LIBNSL 1
#define HAVE_LIBRESOLV 1
#define STDC_HEADERS 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_UNISTD_H 1
#define HAVE_SYS_POLL_H 1
#define HAVE_PTHREAD_H 1
#define HAVE_GETOPT_H 1
#define HAVE_SYSLOG_H 1
#define HAVE_ICONV_H 1
#define HAVE_ZLIB_H 1
#define HAVE_STDLIB_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_SOCKIO_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_NET_IF_H 1
#define HAVE___FUNCTION__ 1
#define HAVE___FUNC__ 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_SELECT 1
#define HAVE_SOCKET 1
#define HAVE_STRDUP 1
#define HAVE_GETOPT_LONG 1
#define HAVE_LOCALTIME_R 1
#define HAVE_GMTIME_R 1
#define HAVE_SRANDOM 1
#define HAVE_FUNC_GETHOSTBYNAME_R_5 1
#define HAVE_SOCKLEN_T 1
#define HAVE_GETOPT_IN_STDIO_H 1
#define HAVE_REGEX_H 1
#define HAVE_REGEX 1
#define HAVE_PTHREAD_SPINLOCK_T 1
#define HAVE_PTHREAD_RWLOCK 1
#define HAVE_LIBRT 1
#define HAVE_SEMAPHORE 1
#define SUFFIX ""
#define USE_GWMEM_NATIVE 1
#define LOG_TIMESTAMP_LOCALTIME 1
#define ENABLE_COOKIES 1
#define USE_KEEPALIVE 1
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char OCIEnvCreate ();
int
main ()
{
return OCIEnvCreate ();
  ;
  return 0;
}

【问题讨论】:

  • 您混淆了 32 位和 64 位。您的 gcc / 默认位数的目标三元组是多少? file /u/app/oracle/product/11.2/lib/libclntsh.so 能得到什么?

标签: oracle gcc solaris ld


【解决方案1】:

libclntsh.so 是一个 64 位二进制库,您使用 32 位代码链接。检查以确保您拥有正确的库。

编辑:

ELF 64 位 MSB 动态库 SPARCV9 版本 1,动态链接,不 剥离

GCC 64 位工具链在链接到基于 Sparc 平台的库时遇到问题,这可能意味着两种情况之一

  • 字节序?有一点不清楚,你在什么平台下运行 gcc 工具链?
  • 发出此命令gcc --version 并运行此命令file /usr/bin/gcc 以确定可执行文件的二进制类型。并将结果与​​库的二进制类型进行比较...

【讨论】:

  • 我添加了blabla 来源。而且好像不是 32 位的,是吗?
  • 源代码本身不是 32 位的 - 这取决于编译器开关/编译器默认值。但它有 #define SIZEOF_LONG 4 和 64 位 Linux 有 8 字节长(至少在 x86/64 上)所以如果它是从你的编译器自动检测到的,那么它是 32 位的,是的。
  • Hmmmm :-S 这些定义来自“检查 int 的大小... 4 检查 long... 4 的大小”
  • 我不知道通过 configure 强制 64 位编译的最佳方法是什么。你可以试试export CC="gcc -m64",或者你可以在cflags上设置它,例如export CFLAGS="-m64 -O2 -g" - 假设 bash shell - 如果您正在运行 Sun ksh,您可能需要单独的设置/导出
  • --with-cflags="-m64 -O2 -g" 成功了!我赞成这个答案,但@Rup我认为你给出了更重要的建议。所以添加另一个单独的评论,我会用赏金检查它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-17
  • 2013-01-11
  • 1970-01-01
  • 1970-01-01
  • 2022-01-13
  • 1970-01-01
相关资源
最近更新 更多