This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

problem linking Java and C++ code with (gcj and binutils)


Hi folks,

I already put this problem into the GNU-Java mailing list, but they can't
reproduce my problem. None the less it looks like a linker problem.
I'm trying to implement a native Java method by using (GNU-)CNI, but the code
cannot be linked because the linker says that my native method is an undefined
hidden alias:

(...)
gcj  -O0 -g -fPIC "--classpath=./:"  -c de/dbt/simplelibclient/SimpleCPPLib.java
-o de/dbt/simplelibclient/SimpleCPPLib.o
gcj  -O0 -g -fPIC  --main=de.dbt.simplelibclient.SimpleCPPLib
de/dbt/simplelibclient/SimpleCPPLib.o  -oDebug/SimpleLibClient   -LDebug
-L/home/andreas/develop/projects/SimpleCPPLib/Debug -L../SimpleCPPLib/Debug
-lSimpleCPPLib -lgcj
de/dbt/simplelibclient/SimpleCPPLib.o:(.data.rel+0xc): undefined reference to
`hidden alias for de::dbt::simplelibclient::SimpleCPPLib::square(int)'
de/dbt/simplelibclient/SimpleCPPLib.o:(.data.rel+0x68): undefined reference to
`hidden alias for de::dbt::simplelibclient::SimpleCPPLib::square(int)'
collect2: ld gab 1 als Ende-Status zurück

But when looking into my shared lib with "nm -C libSimpleCPPLib.so" the hidden
alias is there.
Linking my gcj-compiled Java-binary-object directly to the g++-compiled
binary-object works fine and produces a working executable.


My platform:
 - gcj version: 4.1.2 20061115
 - binutils version: 2.17.50.0.5 20060927
 - OS: openSUSE 10.2, Linux kernel 2.6.18.8
 - glibc version: 2.5 (20061011)

I also tested a fresh Kubuntu 6.10 installation with gcc 4.1.2-prerelease,
binutils 2.17 and glibc 2.5 installed.
Also I built gcc 4.1.2, gcc 4.2.0 (20070307) and binutils 2.17 from scratch from
the release/snapshot sources but got the same error.

I attached an archive with the gcj/Java stuff and the C++ lib and a simple build
script if you want to test it yourself.
Thanks in advance.

-- 
Mit freundlichen Grueszen, / With kind regards,

  Andreas Bürgel
  Diplom-Informatiker (Ingenieur-Informatik)
  Software-Engineer/-Architect
  http://www.andreas-buergel.de/profile.html

  Unbedingt lesenswerte Site:
  http://www.nachdenkseiten.de


  Entia non sunt multiplicanda sine necessitate.
                            -- William of Ockham

Attachment: simplecpplib_sample.tar.bz2
Description: application/bzip


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]