Trouble building C projects with JNA
Trying to create a small JNA program.
After generating the header file im now trying to build and create the dll file. But this problem 开发者_运维问答arises...
Im using the Netbeans IDE with Cygwin, other C/C++ projects work.
gcc: The -mno-cygwin flag has been removed; use a mingw-targeted cross-compiler.
make[2]: Leaving directory `/cygdrive/c/Users/User/Documents/NetBeansProjects/HelloWorldNative'
make[1]: Leaving directory `/cygdrive/c/Users/User/Documents/NetBeansProjects/HelloWorldNative'
make[2]: * [build/Debug/Cygwin-Windows/_ext/1653581963/HelloWorldNative.o] Error 1
make[1]: * [.build-conf] Error 2
make: * [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
I would really like to get Netbeans to work here as I'm new to JNA and want to be able to quickly make changes and experiment. So having to build it from console evry 5 secs is not preferable:S
I have been working those past days onto implementing a Java + JNA + Cygwin solution. After many attempts and dead ends, I finally come up with a sound solution. My JNA calls are getpwnam, chown and perror, all three implemented into Cygwin1.dll. You may view my full solution which applies to my context at http://vouters.dyndns.org/tima/Linux-OpenVMS-Java-Implementing_chown_in_Java.html
I just hope my coding and documentation style is clear enough for you.
I guess I'm a bit lost. The whole point of JNA is that it frees you from having to write or compile native code. You need to provide more details as to what your native code is doing. Are you trying to compile your own dll, which you then plan to access using JNA? If so, you probably don't have Netbeans set up properly to build a dll. I'm guessing it's trying to build an executible, but can't find a 'main' method.
In the Java/JNA chown code I provide, the DLL I call is Cygwin1.dll, a Cygwin's shipped dll, which contains the three calls I am after (getpwnam, chown and perror).
Why do I need Cygwin1.dll ? Because this is the only DLL on Windows containing these Unix entry points. My purpose still remains to write as much as portable code as I can. MinGW not offering these calls, I had to give up with it.
Microsoft may surely propose something analogue to these Unix calls. However this would have surely caused me to assemble a Windows specific code. I am indeed not looking after this.
In the hope this clarifies
精彩评论