×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

connecting matlab to c language dll

connecting matlab to c language dll

connecting matlab to c language dll

(OP)
hello
i'm trying to use clllib function in matlab i put .dll file and .h file in the same directory as the .m MATLAB file being developed and after that i try to use loadlibrary function but it have some warnings:

>> loadlibrary('t1.dll', 'T1Header.h')
Warning: Message from C preprocessor:
lcc preprocessor warning: C:\Users\MAHNAZ\Documents\MATLAB\T1Header.h:21 No newline at end of
file

> In loadlibrary at 351
Warning: The function 'Add' was not found in the library
> In loadlibrary at 435
Warning: The function 'Function' was not found in the library
> In loadlibrary at 435

when I want to use the calllib function like this: calllib('t1', 'Add', 2,3) matlab gives me an error:

??? Error using ==> calllib
Method was not found.


my header file is:

CODE --> C

#ifndef _T1_HEADER_H_
#define _T1_HEADER_H_
 extern "C"
{
 int Add( int a, int b );   
 void Function( void );
 }
#endif 

my source file is:

CODE --> C

#include <stdio.h>
#include "T1Header.h"
 extern "C"
 {
	int Add( int a, int b )
   {
      return( a + b );
   }

	 void Function( void )
   {
	   printf("DLL Called.\n");
   }

 } 

I use visual c++ 2010 and Matlab 7.6.0(R2008a)

Any suggestions on what is wrong, what I could do to fix this error, or what else I could try to call this .dll from within MATLAB?

RE: connecting matlab to c language dll

To get rid of warnings, add a new blank line at the end of file.

If you're using the MS compiler, use Visual studio to create your DLL. It adds quite a few extra bits like exports, which are missing from your code

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources