Author Topic: Compiling a JNI file in Dev-C++ and Code::Blocks  (Read 20969 times)

Offline kostyabkg

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Compiling a JNI file in Dev-C++ and Code::Blocks
« Reply #15 on: December 09, 2005, 01:04:48 pm »
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\kostya\My Documents\cpp\test4\Makefile.win"
Executing  make...
make.exe -f "C:\Documents and Settings\kostya\My Documents\cpp\test4\Makefile.win" all
dllwrap.exe --output-def libMyImpOfPrompt.def --implib libMyImpOfPrompt.a Prompt.o  -L"C:/Dev-Cpp/lib" --no-export-all-symbols --add-stdcall-alias   -o MyImpOfPrompt.dll

dllwrap.exe: no export definition file provided.
Creating one, but that may not be what you want

Execution terminated
Compilation successful
*************************************************

Is it what you are talking about or probably I got something wrong? Probably wrong...

Anyhow, Dev-C++ seems to be be using "Make" to produce dll's. Is there such a planned feature for CodeBlocks to make it generate make files? It seems like for now I have to write ones myself.
« Last Edit: December 09, 2005, 01:08:11 pm by kostyabkg »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Compiling a JNI file in Dev-C++ and Code::Blocks
« Reply #16 on: December 09, 2005, 01:06:42 pm »
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).

Michael

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5192
Re: Compiling a JNI file in Dev-C++ and Code::Blocks
« Reply #17 on: December 09, 2005, 01:09:38 pm »
Kostyabkg,

I also used dev-cpp in the past (and are still using it a little bit), I have loved dev-cpp, I still do, but for the time has come to say goodbye to dev-cpp.
Why ?
1) Well, the number of bugs of dev-cpp is becoming very high (I remember the days , where the total amount of bugs was below 40-50).
I have reported a huge amount of bug reports some years ago, and the majority of them got fixed real soon, and requested features got added also rather quickly, by the dev-cpp team. Note, at that time one of the dev-cpp team members was Yiannis, aka Mandrav.
Then at a given moment I noticed the progress in dev-cpp to slow down, I think it was around the time that Yiannis was no longer showing up in the cvs commits ;-). Some new developers joined the team and again there was a boost in fixes etc ...
But now for over then 9 months no new release has happened. And the latest cvs action on the sources is 3 months ago, adding code folding.
I am shedding a tear, cause I suspect it is nearly dead. It was a great project and deserves the respect of all of us.

2) CB is better and faster ! ANd very importanly I can be used with nearly any compiler (for compilation, not debugging). To me that is very important, since I manage a lot of code that nees to be run on different platforms.
3) It is written in c++, so I can (and I do) help with debugging CB, fixing bugs, adding plug-ins. I do not know delphi (dev-cpp) and I do not want to learn it (not enough time to learn a new language and environment).

CB is still missing some features that dev-cpp had, just a few example :
- matching braces switching (ctrl-shift-b), well I have implemented that as a plug-in, and Yiannis promised he would add it to the core (any news on that one Yiannis ?? ;-) )
- class/function drop down list in the toolbar section

Don't worry, I think a whole lot of these features will come to CB, and I myself, will do my very best to help implement those and try to be in that way a help to the CB developers.

I think everyone has a preferred IDE, let it be dev-cpp, CB, or M$. Let's be honest M$ Developer Studio is great, but as always you suffer so M$ annoyances. Thoug "I" prefer to work with a smaller and faster IDE, like CB, though several functionality is still missing compared to other IDE's. But hey, look at the potential of CB, this is so promising, and already delivering, that it makes such a nice experience and users journey to use it.
Every day a bug is fixed or some feature is added. When M$ has a bug, well wait 2 to 3 years for their next version ,where everything has changed and maybe, maybe that bug is fixed.
The only thing for us, the community is support the project, try to help, try to be part of the development of CB (does not have to mean "develop", but using/testing/feedback/...), and enjoy "our" product to grow and get better day by day.

OK, enough evangelism.
Time to debug a bit, cause we want to get rid of some of those nasty bugs in CB ;-)

Cheers,
Lieven

Offline kostyabkg

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Compiling a JNI file in Dev-C++ and Code::Blocks
« Reply #18 on: December 09, 2005, 01:22:07 pm »
Thank you, Lieven  :D

Yes, I tried switching to Dev-C++ compiler. The same thing... 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?

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Compiling a JNI file in Dev-C++ and Code::Blocks
« Reply #19 on: December 09, 2005, 01:52:08 pm »
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 :)....

Michael

Offline kostyabkg

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Compiling a JNI file in Dev-C++ and Code::Blocks
« Reply #20 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)
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)
, 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

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Compiling a JNI file in Dev-C++ and Code::Blocks
« Reply #21 on: December 10, 2005, 07:18:26 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)
Could you explain a little further, please?
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").

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)
, but what's your opinion?
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: [Select]
gcc -shared -o bridgeC.dll bridgeC.o bridgeC.def

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 ----

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.

Also where I can find some easy-to-digest information on .DEF,.A, .O files and how MinGW compiler works?

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

  • Guest
Re: Compiling a JNI file in Dev-C++ and Code::Blocks
« Reply #22 on: March 23, 2008, 01:59:12 am »
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++)
« Last Edit: March 23, 2008, 02:17:54 am by Jacek_FH »

salin-ra

  • Guest
Re: Compiling a JNI file in Dev-C++ and Code::Blocks
« Reply #23 on: October 03, 2011, 02:54:50 am »
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?


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