Re: Calling a matlab dll in java



Dear Wojceich:

I have followed all your instruction above and got one more problem
as follows.

If I use the following compile parameters

C:\temp\CallingAMatlabDLLInJava>cl -I"C:\Program
Files\Java\jdk1.5.0_06\include" -I"C:\Program
Files\Java\jdk1.5.0_06\include\win32" -I"C:\Program
Files\MATLAB704\extern\include" -I"C:\Program
Files\MATLAB704\extern\lib\win32\microsoft\msvc60" -I"C:\
Program Files\Microsoft Visual Studio\VC98\MFC\SRC" -LD
JNITest_JNITest.cpp -Felibjnitest.dll

I got some warning from compiler as follows:

C:\Program Files\Microsoft Visual Studio\VC98\include\istream(547) :
warning C4530: C++ exception handler used, but unwind se
mantics are not enabled. Specify -GX
C:\Program Files\Microsoft Visual Studio\VC98\include\ostream(234) :
warning C4530: C++ exception handler used, but unwind se
mantics are not enabled. Specify -GX
C:\Program Files\Microsoft Visual
Studio\VC98\include\ostream(229) : while compiling class-template
member function '
class std::basic_ostream<char,struct std::char_traits<char>
&__thiscall std::basic_ostream<char,struct
std::char_traits<cha
r> >::put(char)'
C:\Program Files\Microsoft Visual Studio\VC98\include\ostream(234) :
warning C4530: C++ exception handler used, but unwind se
mantics are not enabled. Specify -GX
C:\Program Files\Microsoft Visual
Studio\VC98\include\ostream(229) : while compiling class-template
member function '
class std::basic_ostream<unsigned short,struct
std::char_traits<unsigned short> > &__thiscall
std::basic_ostream<unsigned sho
rt,struct std::char_traits<unsigned short> >::put(unsigned
short)'
C:\Program Files\Microsoft Visual Studio\VC98\include\istream(46) :
warning C4530: C++ exception handler used, but unwind sem
antics are not enabled. Specify -GX
C:\Program Files\Microsoft Visual
Studio\VC98\include\istream(41) : while compiling class-template
member function 'b
ool __thiscall std::basic_istream<char,struct
std::char_traits<char> >::ipfx(bool)'
C:\Program Files\Microsoft Visual Studio\VC98\include\istream(46) :
warning C4530: C++ exception handler used, but unwind sem
antics are not enabled. Specify -GX
C:\Program Files\Microsoft Visual
Studio\VC98\include\istream(41) : while compiling class-template
member function 'b
ool __thiscall std::basic_istream<unsigned short,struct
std::char_traits<unsigned short> >::ipfx(bool)'
C:\Program Files\Microsoft Visual Studio\VC98\include\xstring(525) :
warning C4530: C++ exception handler used, but unwind se
mantics are not enabled. Specify -GX
C:\Program Files\Microsoft Visual
Studio\VC98\include\xstring(521) : while compiling class-template
member function '
void __thiscall std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char>
::_Copy(unsigned int)'
C:\Program Files\Microsoft Visual Studio\VC98\include\ostream(296) :
warning C4530: C++ exception handler used, but unwind se
mantics are not enabled. Specify -GX
C:\Program Files\MATLAB704\extern\include\mclmcr.h(698) : see
reference to function template instantiation 'class std
::basic_ostream<char,struct std::char_traits<char> >
&__cdecl std::operator <<(class
std::basic_ostream<char,struct std::char
_traits<char> > &,const char *)' being compiled
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/dll
/implib:libjnitest.lib
/out:libjnitest.dll
JNITest_JNITest.obj
Creating library libjnitest.lib and object libjnitest.exp

Then I add the GX switch and get the following from screen:
C:\temp\CallingAMatlabDLLInJava2>cl -I"C:\Program
Files\Java\jdk1.5.0_06\include" -I"C:\Program
Files\Java\jdk1.5.0_06\includ
e\win32" -I"C:\Program Files\MATLAB704\extern\include" -I"C:\Program
Files\MATLAB704\extern\lib\win32\microsoft\msvc60" -I"C:
\Program Files\Microsoft Visual Studio\VC98\MFC\SRC" -LD
JNITest_JNITest.cpp -GX -Felibjnitest.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

JNITest_JNITest.cpp
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/dll
/implib:libjnitest.lib
/out:libjnitest.dll
JNITest_JNITest.obj
Creating library libjnitest.lib and object libjnitest.exp

The real problem comes from here:)
If I run the java main program, I got some errors as follows:

C:\temp\CallingAMatlabDLLInJava2>java JNITest
hello START
Exception in thread "main" java.lang.UnsatisfiedLinkError:
initializeApplication
at JNITest.initializeApplication(Native Method)
at JNITest.main(JNITest.java:33)

So what should I do?

Thank you so much for your great helps:)
-Daniel
.



Relevant Pages

  • Re: Why cant compile xstring?
    ... You have a warning which is treated as an error: ... C++ exception handler used, ... If your project is user mode one, then specify /EHsc for the compiler by ... but unwind semantics are not enabled. ...
    (microsoft.public.development.device.drivers)
  • Warning C4530, exception handling
    ... "warning C4530: C++ exception handler used, but unwind semantics are not ... Specify -GX" ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: reading file backwards and parsing
    ... a warning, it should have prevented the program from compiling ... I suspect you're operating the compiler in a non- ... > trying to read the log file backwards and compare the first column ...
    (comp.lang.c)
  • Re: Sbcl feature - symbol occuring at toplevel is not reported with warning
    ... but sbcl compiles such a file without warning. ... ; compiling V ... ; compiling (PRINC:ONE) ...
    (comp.lang.lisp)
  • Re: What is the proper way to instantiate a class?
    ... so wee need a language that can specify ... Most SV tools proceed by compiling design units (=packages, ... Once a package is compiled into a library, ... # Loading ./out/top.thing_pkg ...
    (comp.lang.verilog)