views:

47

answers:

1
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

Can anyone give me an idea why ld does not work correctly here

(this long command has been taken from configure which is not performing right, because of this error)

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

The 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;
}
+2  A: 

libclntsh.so is a 64 bit binary library which you are linking with a 32bit code. Check to make sure you have the right library.

Edit:

ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped

GCC 64-bit toolchain is having trouble linking against a library built on Sparc platform which could mean either one of two things

  • Endianess? One thing that is not clear, what platform are you running the gcc toolchain under?
  • Issue this command gcc --version and also run this command file /usr/bin/gcc to determine the executable's binary type. And compare the results with what's the library's binary type is...
tommieb75
i've added the `blabla` source. and seems like it is not 32bit, is it?
zerkms
The source isn't 32-bit per-se - that depends on the compiler switches / compiler default. But it's got `#define SIZEOF_LONG 4` and 64-bit Linux has 8-byte longs (on x86/64 at least) so if it's autodetected that from your compiler then it is 32-bits, yes.
Rup
Hmmmm :-S those defines came from "checking size of int... 4checking size of long... 4"
zerkms
I don't know what the best way to force 64-bit compile through configure is. You can try `export CC="gcc -m64"`, or maybe you could set it on the cflags e.g. `export CFLAGS="-m64 -O2 -g"` - assuming bash shell - you may need separate set / export if you're running the Sun ksh
Rup
`--with-cflags="-m64 -O2 -g"` did the trick! i've upvoted this answer, but @Rup i think that you gave more significant advice. So add another separated **comment** and I will check it with bounty.
zerkms
@tommieb75: gcc is 32bit "/usr/local/bin/gcc: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped, no debugging information available"
zerkms
and to be clear - even though i've get configure successfull - `gmake` has failed... but i'm in one step closer now ;-)
zerkms
The gcc binary is 32-bit, but it can build 64-bit libraries and binaries. If you can't figure out how to get the -m64 flag to pass through into the Makefile that `configure` creates, and you're not particularly looking for a 64-bit build, you could try altering other environment variables so it picks up the 32-bit Oracle library instead; don't have an 11g version to check at the moment but earlier versions used to have an ORACLE_HOME/lib32 as well.
Alex Poole