The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 external DLL cannot find function (my challenge w)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

shafei

USA
49 Posts

Posted - 01/21/2012 :  07:26:54 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi, The problem is that I am trying to convert some of my codes from C++ to DLL so they run faster. To do this I started learning how to create DLL files (using VS 2010) and then implement them in Origin C. Unfortunately I get an error that I brought in the subject. The problem is that I am doubtful if it is the problem with the DLL file that I generate using VS or there are something about Origin that I need to figure out!
I started with extremely simple code:

#include "stdafx.h" //This header was included in the file VS //generated

int multiple(int t)
{
int i;
i = 2 * t;
return i;
}

Then I made a dll file with help of some videos online (http://www.youtube.com/watch?v=I0uGEJKcyik), generated separate header file using this link: http://www.originlab.com/www/support/resultstech.aspx?language=english&ID=997

and then wrote a simple code in Origin to run the dll file.
#include <Origin.h>
#include "C:\Creator\lastTest\lastTest\lastTest.h"

int MyDLLTest()
{
int k;
int j;
j =2;
k = multiple (2);
return k;
}

Unfortunately I constantly get this error that external DLL cannot find function ..... multiple.
I would really appreciate your help.
Thanks

eparent

118 Posts

Posted - 01/23/2012 :  3:26:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You need to export your function. Did you add the function name to your .def file? It should be listed under EXPORTS.

Example .def file:

LIBRARY

EXPORTS
    multiple

Go to Top of Page

shafei

USA
49 Posts

Posted - 01/23/2012 :  3:43:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I create DLL file in VC 2010, and I do not see any folder named export. I have "External dependencies", "Header Files", "Resource Files", and "Source Files" folders in VC project.
Go to Top of Page

eparent

118 Posts

Posted - 01/23/2012 :  3:55:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In VC, under Source Files, you should see a .def file listed. Open this file and under EXPORTS add the names of the functions you want to export.

quote:
Originally posted by shafei

I create DLL file in VC 2010, and I do not see any folder named export. I have "External dependencies", "Header Files", "Resource Files", and "Source Files" folders in VC project.


Go to Top of Page

shafei

USA
49 Posts

Posted - 01/23/2012 :  5:41:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I only have three .cpp files in the "source files" folder. That's what VC automatically generate!
Go to Top of Page

shafei

USA
49 Posts

Posted - 01/25/2012 :  6:42:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I actually solved my problem! Instead of using VC directly to generate a dll file, I used the one that Origin has already prepared for fitting functions. I made the required changes, and tried it for a simple function. It worked. Origin has also several pages explaining how to call and use dll. Do as it is said in the file. Some of the links are:
http://ocwiki.originlab.com/index.php?title=Category:Access_an_External_DLL

http://ocwiki.originlab.com/index.php?title=OriginC:Calling_External_DLLs

http://www.originlab.com/www/support/resultstech.aspx?language=english&ID=997

In particular, I found the third link very useful.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000