This is the mail archive of the java@gcc.gnu.org mailing list for the Java 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]

Re: GCJ compilation problems


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Dienstag, 1. Juni 2004 11:47 schrieb Ranga Reddy M - CTD ,Chennai.:
> Hi ,
>
> I do not have much idea about the gcj. I started working on it..
>
> Could you please let me know about the compilation procedure for
> the following programs.
>
> I am calling java from C++, My C++ programe is here
> and java programs(test2.java) has import * statments....(package is
> test.java).
>
>
> I am getting the following error if I run the programe as
>
> >gcj  -o Mytest  test2.java javatest.cpp -lstdc++ -lgcj
>
> Undefined                       first referenced
>  symbol                             in file
> temp::test::test()                  /var/tmp//ccEZC6Eg.o
> temp::test::class$                  /var/tmp//ccEZC6Eg.o
> ld: fatal: Symbol referencing errors. No output written to 1
> collect2: ld returned 1 exit status
>
> But, this works fine except only one warning
>
> >gcj  -o Mytest  test2.java test.java javatest.cpp -lstdc++ -lgcj

You cant compile C++ code with a Java compiler and you dont need to 
link libgcj (and libstdc++ too) explicitely because they are 
implicitely linked.

Best is to compile each source file to an object file and then link 
all together with gcj.

g++ -c javatest.cpp
gcj -c test2.java
gcj -c test.java
gcj -o test test.o test2.o javatest.o

Thats the easy way most projects to this.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAvFhEWSOgCCdjSDsRAmP/AJoD+fqLyb/QDPyzGMNzZewGxPbwoQCfeyWw
dJxj0JuwKoT45xKvt91BZXY=
=/DED
-----END PGP SIGNATURE-----


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