Linking problem gcj and c++

Carsten Rasmussen carsten.rasmussen@silicide.dk
Mon Jun 25 10:59:00 GMT 2007


Dear GCJ org
I have a linking problem with gcj.
I it my first time I try to link java code to c++ using the CNI 
interface may be I missed something in the documentation but I am unable 
to find out what it is.
I really don't know what I am doing wrong. To illustrate the problem I 
have made an simple example based on one of the example on the web.
-----------------------
ask:~/src/vampyra/netcon/gcjtest> make clean all
rm -f *.o
g++ -v -c test.cc;
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v 
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-mpfr --with-tune=i686 
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
 /usr/lib/gcc/i486-linux-gnu/4.1.2/cc1plus -quiet -v -D_GNU_SOURCE 
test.cc -quiet -dumpbase test.cc -mtune=i686 -auxbase test -version -o 
/tmp/ccp5AbTq.s
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory 
"/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2
 /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/i486-linux-gnu
 /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.1.2/include
 /usr/include
End of search list.
GNU C++ version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) 
(i486-linux-gnu)
        compiled by GNU C version 4.1.2 20061115 (prerelease) (Debian 
4.1.1-21).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129398
Compiler executable checksum: 183d42a838ed2b7313bffcb8f2f2fda7
 as -V -Qy -o test.o /tmp/ccp5AbTq.s
GNU assembler version 2.17.50 (i486-linux-gnu) using BFD version (GNU 
Binutils for Debian) 2.17.50.20070426
#### Infomation      ####
uname -a
Linux ask 2.6.14-rc1 #3 SMP PREEMPT Thu Oct 13 17:35:06 CEST 2005 i686 
GNU/Linux
pwd
/home/carsten/src/vampyra/netcon/gcjtest
gcj --version
gcj (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

g++ --version
g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

#### End Info-list   ####
gcj -v -lgcj test.o
Using built-in specs.
Reading specs from /usr/lib/gcc/i486-linux-gnu/4.1.2/libgcj.spec
rename spec startfile to startfileorig
rename spec lib to liborig
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java 
--prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
--enable-java-awt=gtk-default --enable-gtk-cairo --enable-plugin 
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre 
--with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)
 /usr/lib/gcc/i486-linux-gnu/4.1.2/collect2 --eh-frame-hdr -m elf_i386 
-dynamic-linker /lib/ld-linux.so.2 
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o 
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crti.o 
/usr/lib/gcc/i486-linux-gnu/4.1.2/crtbegin.o 
-L/usr/lib/gcc/i486-linux-gnu/4.1.2 -L/usr/lib/gcc/i486-linux-gnu/4.1.2 
-L/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib -L/lib/../lib 
-L/usr/lib/../lib -lgcj test.o -lgcc_s -lgcc -lgcj -lm -lpthread -lrt 
-lz -ldl -lgcc_s -lgcc -lc -lgcc_s -lgcc 
/usr/lib/gcc/i486-linux-gnu/4.1.2/crtend.o 
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crtn.o
test.o: In function `hidden alias for testclass::testclass()':
test.cc:(.text+0xe5): undefined reference to `java::lang::Object::Object()'
test.cc:(.text+0xea): undefined reference to `vtable for testclass'
test.o: In function `hidden alias for testclass::testclass()':
test.cc:(.text+0x103): undefined reference to `java::lang::Object::Object()'
test.cc:(.text+0x108): undefined reference to `vtable for testclass'
collect2: ld returned 1 exit status
make: *** [all] Error 1
----------------------
You can see that the linker can't find th java::lang::Object::Object().
I believer that the Object() symbol must be in the libgcj.so file?
Why can the linker find it?

Could any body help we solve this problem.

-- 

Yours sincerely

Carsten Bleser Rasmussen
Technical Director - R & D
----------------------
Silicide (SCION)
DK-2800 Diplomvej 377
Denmark (Kgs. Lyngby)
(tlf) (+45)70225579
(fax) (+45)70225569
(mob) (+45)40682262
http://www.silicide.dk
-----------------------

-------------- next part --------------

.PHONY: info

all: test.o info
	gcj -v -lgcj test.o
	nm test.o

test.o: test.cc
	g++ -v -c test.cc; 

info:
	@echo "#### Infomation      ####";
	uname -a
	pwd
	gcj --version
	g++ --version
	@echo "#### End Info-list   ####";

clean:
	rm -f *.o
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cc
Type: text/x-c++src
Size: 738 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20070625/aedd57b2/attachment.bin>


More information about the Gcc-help mailing list