g++ symbol versioning. Set it to GCC_3.0 using version 4 of g++

0

I need to implemente a Java class which uses JNI to control a fiscal printer in XUbuntu 8.10 with sun-java6-jdk installed.

The structure is the following:

EpsonDriver.java loads libEpson.so

libEpson is linked dynamically with EpsonFiscalProtocol.so ( provided by Epson, no source available ) and pthread

I use javah to generate the header file, and the code compiles. Then I put the libEpson.so in $JAVA_HOME/jre/lib/i386, and EpsonDriver.java uses an static initializar

System.loadLibrary("libEpson")

That part works, however, when I try to use any of the methods I get an unsatisfiedLinkError exception.

Some time ago, a coworker did a version that works, and using objdump -Dslx I got the following:

Program Header:
    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12
         filesz 0x0000ccc4 memsz 0x0000ccc4 flags r-x
    LOAD off    0x0000d000 vaddr 0x0000d000 paddr 0x0000d000 align 2**12
         filesz 0x00000250 memsz 0x00044a5c flags rw-
 DYNAMIC off    0x0000d014 vaddr 0x0000d014 paddr 0x0000d014 align 2**2
         filesz 0x000000f0 memsz 0x000000f0 flags rw-
    NOTE off    0x000000d4 vaddr 0x000000d4 paddr 0x000000d4 align 2**2
         filesz 0x00000024 memsz 0x00000024 flags r--
   STACK off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2
         filesz 0x00000000 memsz 0x00000000 flags rw-

Dynamic Section:
  NEEDED               EpsonFiscalProtocol.so
  NEEDED               libpthread.so.0
  NEEDED               libstdc++.so.6
  NEEDED               libm.so.6
  NEEDED               libc.so.6
  SONAME               libcom_tichile_jpos_EpsonSerialDriver.so
  INIT                 0x00007254
  FINI                 0x0000ba08
  GNU_HASH             0x000000f8
  STRTAB               0x00001f50
  SYMTAB               0x00000ae0
  STRSZ                0x00002384
  SYMENT               0x00000010
  PLTGOT               0x0000d108
  PLTRELSZ             0x00000008
  PLTREL               0x00000011
  JMPREL               0x0000724c
  REL                  0x000045c4
  RELSZ                0x00002c88
  RELENT               0x00000008
  TEXTREL              0x00000000
  VERNEED              0x00004564
  VERNEEDNUM           0x00000002
  VERSYM               0x000042d4
  RELCOUNT             0x000000ac

Version References:
  required from libstdc++.so.6:
    0x056bafd3 0x00 05 CXXABI_1.3
    0x08922974 0x00 04 GLIBCXX_3.4
  required from libc.so.6:
    0x0b792650 0x00 03 GCC_3.0
    0x0d696910 0x00 02 GLIBC_2.0

In the recently compiled file I get:

Program Header:
    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12
         filesz 0x00005300 memsz 0x00005300 flags r-x
    LOAD off    0x00005300 vaddr 0x00006300 paddr 0x00006300 align 2**12
         filesz 0x00000274 memsz 0x00010314 flags rw-
 DYNAMIC off    0x00005314 vaddr 0x00006314 paddr 0x00006314 align 2**2
         filesz 0x000000e0 memsz 0x000000e0 flags rw-
EH_FRAME off    0x00004a00 vaddr 0x00004a00 paddr 0x00004a00 align 2**2
         filesz 0x00000154 memsz 0x00000154 flags r--

Dynamic Section:
  NEEDED               libstdc++.so.5
  NEEDED               libm.so.6
  NEEDED               libgcc_s.so.1
  NEEDED               libc.so.6
  SONAME               EpsonFiscalProtocol.so
  INIT                 0x00001cb4
  FINI                 0x00004994
  HASH                 0x000000b4
  STRTAB               0x00000da4
  SYMTAB               0x000004f4
  STRSZ                0x00000acf
  SYMENT               0x00000010
  PLTGOT               0x0000640c
  PLTRELSZ             0x00000270
  PLTREL               0x00000011
  JMPREL               0x00001a44
  REL                  0x000019dc
  RELSZ                0x00000068
  RELENT               0x00000008
  VERNEED              0x0000198c
  VERNEEDNUM           0x00000002
  VERSYM               0x00001874
  RELCOUNT             0x00000004

Version References:
  required from libstdc++.so.5:
    0x056bafd2 0x00 04 CXXABI_1.2
  required from libc.so.6:
    0x09691f73 0x00 03 GLIBC_2.1.3
    0x0d696910 0x00 02 GLIBC_2.0

So I suspect the main diference is the GCC_3.0 symbol

I compile libcom_tichile_EpsonSerialDriver.so with the following command ( from memory as I not at work right now )

g++ -Wl,-soname=.... -shared -I/*jni libraries*/ -o libcom_tichile_jpos_EpsonSerialDriver -lEpsonFiscalProtocol -lpthread

Is there any way to tell g++ to use that symbol version? Or any idea in how to make it work?

EDIT: I have another non-working version with the followin dump:

Program Header:
    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12
         filesz 0x0000bf68 memsz 0x0000bf68 flags r-x
    LOAD off    0x0000cc0c vaddr 0x0000cc0c paddr 0x0000cc0c align 2**12
         filesz 0x000005e8 memsz 0x00044df0 flags rw-
 DYNAMIC off    0x0000cc20 vaddr 0x0000cc20 paddr 0x0000cc20 align 2**2
         filesz 0x000000f8 memsz 0x000000f8 flags rw-
EH_FRAME off    0x0000b310 vaddr 0x0000b310 paddr 0x0000b310 align 2**2
         filesz 0x000002bc memsz 0x000002bc flags r--
   STACK off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2
         filesz 0x00000000 memsz 0x00000000 flags rw-
   RELRO off    0x0000cc0c vaddr 0x0000cc0c paddr 0x0000cc0c align 2**0
         filesz 0x000003f4 memsz 0x000003f4 flags r--

Dynamic Section:
  NEEDED               EpsonFiscalProtocol.so
  NEEDED               libpthread.so.0
  NEEDED               libstdc++.so.6
  NEEDED               libm.so.6
  NEEDED               libgcc_s.so.1
  NEEDED               libc.so.6
  SONAME               libcom_tichile_jpos_EpsonSerialDriver.so
  INIT                 0x000055d8
  FINI                 0x0000a968
  HASH                 0x000000f4
  GNU_HASH             0x00000a30
  STRTAB               0x00002870
  SYMTAB               0x00001410
  STRSZ                0x00002339
  SYMENT               0x00000010
  PLTGOT               0x0000cff4
  PLTRELSZ             0x00000168
  PLTREL               0x00000011
  JMPREL               0x00005470
  REL                  0x00004ea8
  RELSZ                0x000005c8
  RELENT               0x00000008
  VERNEED              0x00004e38
  VERNEEDNUM           0x00000002
  VERSYM               0x00004baa
  RELCOUNT             0x00000001

Version References:
  required from libstdc++.so.6:
    0x056bafd3 0x00 05 CXXABI_1.3
    0x08922974 0x00 03 GLIBCXX_3.4
  required from libc.so.6:
    0x09691f73 0x00 06 GLIBC_2.1.3
    0x0d696914 0x00 04 GLIBC_2.4
    0x0d696910 0x00 02 GLIBC_2.0

Now I think the main difference is in the GCC_3.0 symbol/ABI

EDIT: Luckily, a coworker found a way to talk to the printer using Java

g++
java-native-interface
asked on Stack Overflow Jun 29, 2009 by Ismael • edited Mar 21, 2011 by Bill the Lizard

1 Answer

2

No. They are mean to be incompatible. You have to use a older version of g++.

Also, the different is at libstdc++.so.5 and libstdc++.so.6.

answered on Stack Overflow Jun 29, 2009 by J-16 SDiZ

User contributions licensed under CC BY-SA 3.0