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: gcjh, Headers hierarchy and namespaces


Ok thanks now it finds the headers but compling is ok but not linking
with the following code (which is not using my headers and my library) i got an error :


#include <iostream>
#include <java/lang/String.h>
#include <gcj/array.h>
#include <gcj/cni.h>
#include <gnu/gcj/RawData.h>
#include <java/lang/System.h>
using namespace std;

int main()
{
   std::string cppstr("Hello, C++ String");
   jstring jstr = JvNewStringUTF(cppstr.c_str());
   //::java::lang::System::out->println(jstr);
   cout << jstr;
}

Here what I get with > g++ Exemple.c -o Exemple.exe

/cygdrive/c/DOCUME~1/FBOURG~1/LOCALS~1/Temp/ccey63Ls.o(.text+0x34):Exemple.c: und
efined reference to `___gcj_personality_sj0'
/cygdrive/c/DOCUME~1/FBOURG~1/LOCALS~1/Temp/ccey63Ls.o(.text$_Z14JvNewStringUTFPK
c+0xd):Exemple.c: undefined reference to `__Jv_NewStringUTF'
collect2: ld returned 1 exit status


I tried to specify -Llibgch or -Llibjava but none of them is changing anything.

What can i do ? Thanks


Secondly, I am looking for good documentation on JNI types. Indeed, I compile my Java classes in binary with gcj, then I used gcjh to generate the headers so that people could make c++ programs and use my Java class transformed to binary. I dont want to use JNI to make the two environnement communicate, but to make my Java classes available for native environnements.


Thanks

Regards,

Florian BOURGIER

Bryce McKinlay wrote:

Florian Bourgier wrote:

Indeed, my Java classes were organized in package and I had a tree. So I would have liekd to keep the same tree for the headers. But when I want to include a file like this :

#include "AtomicRecord.h"

int main()
{}

the headers cannot be found. And if I write "D:\test\Partie3-Envt_natif\gcj-gcjh\com\eadstelecom\framework\data\AtomicRecord.h" Then I have the error that Lockable cannot be found un com/eads/etc...
How can I solve this ?


Can I keep my tree ? I have to because if not, there will be classes with the same name and this is impossible .
How can I say to search under a directory for the headers ?


Use <>'s instead of ""'s. ie:

#include <com/eadstelecom/framework/data/AtomicRecord.h>

Then make sure that the base directory (ie the one that contains "com") is included with -I when invoking g++.

Regards

Bryce




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