SCJP, SCJD, SCWCD, SCBCD, SCEA
SCJP, SCJD, SCWCD, SCBCD, SCEA
SCJP, SCJD, SCWCD, SCBCD, SCEA
SCJP, SCJD, SCWCD, SCBCD, SCEA
SCJP, SCJD, SCWCD, SCBCD, SCEA
SCJP, SCJD, SCWCD, SCBCD, SCEA
SCJP, SCJD, SCWCD, SCBCD, SCEA
Originally posted by Jean-Francois Briere:
1- When using gcc you must add the following compiler/linker flags:
-D__int64="long long"
-shared
-Wl,--add-stdcall-alias
So that your command line should look like:
gcc -D__int64="long long" -I"C:\jdk1.5.0_06\include" -I"C:\jdk1.5.0_06\include\win32" -shared -Wl,--add-stdcall-alias -o hello.dll HelloWorldImp.c
Also if your are using gcc under Cygwin you should also use the flag -mno-cygwin to be able to run your program outside Cygwin.
2- When using MS cl.exe and link.exe you should allways first call vcvars32.bat located in the MSVC bin folder
(C:\Program Files\Microsoft Visual Studio 8\VC\bin for instance).
This script sets all the necessary variables to the appropriate values.
There is albsolutely NO NEED to set anything by hand.
And I wouln't call it in autoexec.bat since this will load your system/user environment at any time,
even when you are not building c/c++ files.
3- When you have successfully build your DLL you should either:
a- Put it in a folder already pointed by the Path enviroment variable (usually not a good idea)
b- Update the Path enviroment variable to add the folder where your DLL is located.
You could do that each time just before executing the Java program:
>set Path=yourDllFolder;%Path%
>java YourClass
You could also update your Path enviroment variable once and for all with the help of the 'System Properties' window.
c- (Preferably) Set the folder of your DLL while executing your Java program with the java.library.path property:
> java -Djava.library.path=yourDllFolder YourClass
Regards
Originally posted by Dan Bizman:
It raises the question, however, as to why Sun's JNI tutorial doesn't mention any of this.
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|