GOTCHA: I found the option to solve the compiling problem with MinGW gcc. Use this command line:
gcc -shared -o bridgeC.dll bridgeC.o bridgeC.def
Inside the .def file, only describe the right function name:
--- bridgeC.def ----
EXPORT
sayHelloWorld
--- bridgeC.def ----
The compiler will say something like: Warning: linking sayHelloWorld to sayHelloWorld@2 , but the DLL will work.
you should be able to add:
--add-stdcall-alias to your gcc options
or
wrap all jni available calls with
extern C
jim
wrap all jni available calls withUnfortunately, even this does not solve the problem.
extern C
Yes, the same for me. However it's interesting that in Dev-C++ --add-stdcall-alias is already set in linker options! If I remove it I get the same bloody error with Dev-C++. Maybe it's worth turning to them (Dev-C++ team) and trying to found out, how they managed it to work?
I am having some problems getting my DLL to work properly. I am following the basic Hello World example and seem to be getting a problem.
I am running on Windows XP with, j2sdk1.4.2_04, and using the gcc that comes with Dev-C++ (Bloodshed). The following is the steps I went through.
...
As to me Dev-C++ remains the IDE of my choice. It's friendly for somebody new like me, has a very clean and clear interface. Lots of icons, that help me to remember what i should press to compile the program and what to run it. Also the most of my time I spend with Java, not C, so I need something comfortable to jump to for a few hours and back to Java.
That's something I wanted say about Code::Blocks - I know it's only 1 year old and has an amazing amount of possibilities for a 1 year old IDE, but in my opinion it needs to be a little more friendly to the user. I am sure it won't take much of a programming effort to create BIGGER buttons in a button panel. And also in drop down menus to put the same icon as on the buttons to make memorizing easier (just like they do it MS Office, Dev-C++, ....). I am sure it would attract much more newcomers and spread the popularity of this IDE.
I have the desire to use CodeBlocks, but I need it to produce correct DLL files or I can't work, so I have to stick with something working, because it's main priority for me.Sorry, but did you use the same MinGW version for both C::B and Dev-C++ or different ones? If different ones you can try to make C::B using the MinGW of Dev-C++ (and possibly by using the options that Dev-C++ passes to the compiler/linker).
Also, why even when I manually delete the DLL file and rebuild the project again with CodeBlocks it generates the new DLL file with "time created" fiield set to some time ago? I don't understand this. Shouldn't it be the time of the last compile?I have remarked this too. When I delete the DLL and build a new one, in the DLL properties, the date/time of the creation is not set correctly :?. But if I execute after deleting the DLL an "update" (of the folder containing the DLL), then the newly created DLL has a date/time field set correctly. Na ja, microsoft :)....
But if I execute after deleting the DLL an "update" (of the folder containing the DLL)Could you explain a little further, please?
(sorry, but I am not a makefile expert Embarassed), but what's your opinion?
I am sorry, but I don't understand what you mean by saying:By update, I mean that you click with the right button on the explorer windoows containing the dll and then you chose "update" (I am not sure if "update" is the correct name. I have a German Windows XP, so in my OS it is called "Aktualisieren").QuoteBut if I execute after deleting the DLL an "update" (of the folder containing the DLL)Could you explain a little further, please?
Also do you think that "Makefile" feature in Dev-C++ is the reason it works there? I know:I suggested to use a makefile in C::B, because IMHO, a makefile can be used to "easily" drive the compilation/linking of a project. When I have tried, I have compiled the HelloWorld by using C::B and then with a small workaround and the use of the following command:Quote(sorry, but I am not a makefile expert Embarassed), but what's your opinion?
gcc -shared -o bridgeC.dll bridgeC.o bridgeC.def
Inside the .def file, only describe the right function name:
--- bridgeC.def ----
EXPORT
sayHelloWorld
--- bridgeC.def ----
Also where I can find some easy-to-digest information on .DEF,.A, .O files and how MinGW compiler works?
I am sorry for being not clear enough. I get this error when I launch the java file. I just followed the tutorial in both cases, but the file compiled by Dev-C++ run correctly while being invoked by my java program, whereas when my java program is trying to invoke the DLL file created by Code::Blocks it gives me this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: displayHelloWorld
at HelloWorld.displayHelloWorld(Native Method)
at HelloWorld.main(HelloWorld.java:9)
In this java trail it says about an error, but the error they quote there is a little different from the one I get. It just seems to me that this file somehow doesn't "interact" with my Java program, but what the problem? I don't have a clue... And why Dev-C++ works?