am binding java with C, problem is in compiling hello.c file. where and how to compile ?.C file, i m using win-XP command prompt and tried with command 'cl', and also 'gcc' with cygwin both gives error ' command not found' ..
Well, first question: do you have CL (Visual C++, a commercial product) or gcc (available in Cygwin as an optional install) actually installed? Neither will come with Windows itself.
first of all thanks for your reply,
i dont have CL but i used intall now link on cygwin.com to download. it is installed.. i typed gcc command in cygwin's bash.
The default cygwin install doesn't include gcc and the other tools you'll need. You have to run the setup.exe program again, find gcc under the "Development" category, and install it -- it should install the other things automatically.
i have downloaded the appropriate enviorment supporting 'gcc'. i tried to compile .C file as
gcc --mno-cygwin -D __int64="long long" -I jdk/include/ -I jdk/include/win32 -shared -Wl,--stdcall-alias -o HelloNative.dll Hellonative.c where jdk is directory containing jdk, it is giving error no such file or directory.
refrence-- core java2 volume2 advanced features.. page 854
thank you,
now the only error is gcc: HelloNative.C : no such file or directory. i have HelloNative.java, HelloNativeTest.java, HelloNative.C(written in notepad), HelloNative.h in different directory(e:\).
Hmmm. Are you sure that HelloNative.C is not actually named HelloNative.C.txt ? NotePad will do that sometimes!
If you use cygwin's "ls" command to list the files in a directory, you'll see the true name of the file. If it's got that .txt on the end you could say
zius oram wrote:i checked it is HelloNative.c , i am confused how gcc will come to know about my C file? as no where i am mentioning its location.
Ah. The command you showed assumes that the .c and .h files are both in the same place -- the current directory -- when you type the command. Put the files in the same directory if they're not, and then use "cd" to change to that directory.
i did it, now error has changed to
cc1: error:unrecogniszed command line option "-fmno-cygwin"
when i removed one hifen (-) shown above(--mno)and now (-mno) it gives me error
HelloNative.c :1:24: HelloNative.h: no such File or Directory
HelloNative.c:4:error: syntax error before "void"
HelloNative.c:4:error: parse error before '*' token my HelloNative.c file is as...
did it, now it is
In file included from HelloNative.c:1:
HelloNative.h:2:17: jni.h:no such file or directory
In file included from HelloNative.c:1:
HelloNative.h:15:error: syntax error before "void"
HelloNative.h:16:error: parse error before '*' token
HelloNative.h:16:warning: data defination has no type or storage class
HelloNative.c:4:error: syntax error before "void"
HelloNative.c:4:error: parse error before '*' token
jni.h should be in that "jdk/include" directory. You might not have the path quite right. Make sure you can use "ls" to see the contents of the path you include there.
Thank You its working........
i followed all the steps specified by you, but the mistake i made was, I Omitted The Space in " \ Files", from the command you gave above.