LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using matlab c shared library in CVI

Hi,

 

I'm trying to create a c shared library in MATLAB, then use that library in CVI.

Unfortunately, I am having zero success..

 

I have tried following the instructions given by a previous post with no luck.

http://forums.ni.com/ni/board/message?board.id=180&message.id=19209&query.id=467329#M19209

 

Initially, I was getting an identical problem as what is described in the post linked above. The compiler I was using in MATLAB was either "Lcc-win32 C 2.4.1" or "Microsoft Visual C++ .NET 2003", both produced the same result.

 

I have since got the MSVC express edition and am now using it's compiler, "Microsoft Visual C++ 2008".

This produces a .lib file which will CVI will load without reporting any errors, but at runtime I get a general protection fault when the .dll is called.

I'm at the point where I've tried everything I can think of.

 

The MATLAB function which I am trying to export is purely demonstrative (at this point), it simply adds 2 numbers.

-But I have not even call it in the CVI c file yet; The general protection fault occurs when CVI tries to initialise the MATLAB runtime.

 

I'm using CVI version 9.0 and MATLAB version 2008a (with Microsoft Visual C++ 2008 compiler)

 

Any thoughts or suggestions would be greatly appreciated.

 

Ta,

Diz.

 

 

 

0 Kudos
Message 1 of 4
(4,197 Views)

Hi Diz

 

you can find an example in:

C:\Documents and Settings\All Users\Documents\National Instruments\CVIx\samples\activex\matlab

Regards
DianaS
0 Kudos
Message 2 of 4
(4,195 Views)

Hi DianaS,

 

Thanks, this sample runs OK after rebuilding the ActiveX controller.

In the short-term I'll use this ActX interface, but in the longer term I still want to get the shared library working for two reasons;

(a) I need to distribute the end app to another machine, and would rather not purchase another (expensive) matlab licence, and

(b) a shared library should run faster.

 

cheers,

Diz

0 Kudos
Message 3 of 4
(4,171 Views)

Hello, I am having the same exact problem as Diz...

 

 

I am also trying to create a c shared library in MATLAB, then use that library in CVI.  Unfortunately, I am having zero success in CVI (works just fine in MSVC).

 

I have also tried following the instructions given by a previous post with no luck.

http://forums.ni.com/ni/board/message?board.id=180&message.id=19209&query.id=467329#M19209

 

Initially, I was also getting an identical problem as what is described in the post linked above. (The compiler I was using in MATLAB was "Lcc-win32 C".)

 

I MSVC compiler, "Microsoft Visual C++ 2005".  This produces a .lib file which will CVI will load without reporting any errors, but at runtime I get a general protection fault when the .dll is called.

 

I'm also at the point where I've tried everything I can think of.

 

The MATLAB function which I am trying to export is also purely demonstrative (at this point), it simply adds 2 numbers.

-But I have not even call it in the CVI c file yet; The general protection fault occurs when CVI tries to initialise the MATLAB runtime.

 

I'm using CVI version 8.5 and MATLAB version 2008a (with Microsoft Visual C++ 2005 compiler)

 

Please advise; Thanks!

 

Andre

0 Kudos
Message 4 of 4
(4,023 Views)