User forums > Using Code::Blocks

Compiling a JNI file in Dev-C++ and Code::Blocks

<< < (5/5)

kostyabkg:
I am sorry, but I don't understand what you mean by saying:

--- Quote ---But if I execute after deleting the DLL an "update" (of the folder containing the DLL)
--- End quote ---
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:

--- Quote ---(sorry, but I am not a makefile expert Embarassed)
--- End quote ---
, but what's your opinion?
Also where I can find some easy-to-digest information on .DEF,.A, .O files and how MinGW compiler works?

Kostya

Michael:

--- Quote from: kostyabkg on December 10, 2005, 01:07:36 pm ---I am sorry, but I don't understand what you mean by saying:

--- Quote ---But if I execute after deleting the DLL an "update" (of the folder containing the DLL)
--- End quote ---
Could you explain a little further, please?

--- End quote ---
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").


--- Quote from: kostyabkg on December 10, 2005, 01:07:36 pm ---Also do you think that "Makefile" feature in Dev-C++ is the reason it works there? I know:

--- Quote ---(sorry, but I am not a makefile expert Embarassed)
--- End quote ---
, but what's your opinion?

--- End quote ---
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:


--- Code: ---gcc -shared -o bridgeC.dll bridgeC.o bridgeC.def

--- End code ---

and a modification of the def file as described here:


--- Quote ---Inside the .def file, only describe the right function name:
--- bridgeC.def ----
EXPORT
sayHelloWorld
--- bridgeC.def ----

--- End quote ---

I generated a valid Dll. Unfortunately, I was unable to do this directly within C::B :(. May be with a makefile it would be possible.

Remark: in the GCC command and def file, you should change the name of the .def, .o, etc. files with your correct names.

Dev-C++ should do/use something that generates a correct def file and consequently a valid DLL. But exactly what, I do not know.


--- Quote from: kostyabkg on December 10, 2005, 01:07:36 pm ---Also where I can find some easy-to-digest information on .DEF,.A, .O files and how MinGW compiler works?

--- End quote ---

About MinGW, you can look at here (they should be good starting points):

http://www.mingw.org/
(try also the MinGW forum)
http://en.wikipedia.org/wiki/MinGW
http://gcc.gnu.org/

For .DEF, this could be useful:

http://www.mingw.org/docs.shtml
(and search for the section "How to create a def file for a dll")
http://www.geocities.com/yongweiwu/stdcall.htm

If I will find something interesting in the next few days, I will post it here.

Hope this would help.

Best wishes,
Michael

Jacek_FH:
Workaround:

Other linker options:
-Xlinker --add-stdcall-alias

Works for me, but it was difficult to find it out. Is there any chance to fix it ?
(it = parsing linker options to linker not mingw-g++)

salin-ra:

--- Quote from: kostyabkg on December 07, 2005, 09:29:23 pm ---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?

--- End quote ---


I have the same problem in generating a DLL with CB ....someone could compile a dll in BC? validates

Navigation

[0] Message Index

[*] Previous page

Go to full version