Building DLLs in VC++

Reply

Join Date: Sep 2005
Posts: 4
Reputation: openhiem is an unknown quantity at this point 
Solved Threads: 0
openhiem openhiem is offline Offline
Newbie Poster

Building DLLs in VC++

 
0
  #1
Sep 2nd, 2005
hey all, I just joined this community. I have been programming quite a bit in C/C++, however, this is the first time i am doing something like this. I have the Microsoft VC++ 6 package. The idea is to use the functions i have already written in the past( a lot of them ), in a current MATLAB project. The solution that i can think of is to convert the functions and the libraries into a DLL so that i can use loadlibrary in MATLAB and call them out. however, i cant seem to make DLL files. I have done some reading, but it is not helping. Can anyone help me out with this. The problem is to build DLLs in VC++ and then call them using MATLAB. In case there is a better method to call the C++ functions in MATLAB, i am open to that too. I just need to get some stuff working in MATLAB without having t recode it, since recoding will take me a HELL lot of time. Help me out folks ... Thanks

Cheers
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 15,976
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 506
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Building DLLs in VC++

 
0
  #2
Sep 7th, 2005
I could tell you how to do it in ms visual c++4 if thats ok?
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 4
Reputation: openhiem is an unknown quantity at this point 
Solved Threads: 0
openhiem openhiem is offline Offline
Newbie Poster

Re: Building DLLs in VC++

 
0
  #3
Sep 7th, 2005
Yes that could work too, i may get some hints based on that. I am trying another approach now which is very lenghty and "dirty" to say the least. I am trying to get executables. I am making executables of all the functions, due to which i am loosing the nice class structure i had built. I will then be calling these executables in MATLAB, using the system command.

However, if you can get me to make a DLL to be loaded in MATLAB, it would be great.

Thanks a lot

Cheers
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 15,976
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 506
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Building DLLs in VC++

 
0
  #4
Sep 7th, 2005
Ill get back to you but it may be a while as I will have to reinstall the software to check it out first - ok?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,151
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1435
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: Building DLLs in VC++

 
0
  #5
Sep 7th, 2005
in VC++ 6.0 IDE create a "win32 Dynamic-Link Library" project. Step 1 of the wizard has 3 radiao buttons select "a DLL project that exports some symbols" then press Finish button. The wizard will generate the DLL project. Look at the *.cpp and *.h files. They will show you how to add your own functions and how to "export" them so that they can be used by other applications. Just copy-past the functions or files into that project, export them as illusterated.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 4
Reputation: openhiem is an unknown quantity at this point 
Solved Threads: 0
openhiem openhiem is offline Offline
Newbie Poster

Re: Building DLLs in VC++

 
0
  #6
Sep 7th, 2005
Thanks Proliant .. appreciate it ..

Ancient.... i have already done that. It makes my DLLs.. but the problem is loading them into MATLAB. When i load them into MATLAB, it does not like it. It says, that all the functions mentioned in the header are missing. I am trying to get around that. Got any ideas ?

Cheers
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 15,976
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 506
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Building DLLs in VC++

 
0
  #7
Sep 8th, 2005
How are you using the DLL'S? You cant just call them and pass arguments like you would an .EXE file.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 4
Reputation: openhiem is an unknown quantity at this point 
Solved Threads: 0
openhiem openhiem is offline Offline
Newbie Poster

Re: Building DLLs in VC++

 
0
  #8
Sep 8th, 2005
first i make the DLLs, with some extra lines of code in the DLLMain() function. This is the function that will call the appropriate original function and pass paramteres to them as needed. The call to DLLMain with the appropriate parameters will be made through MATLAB. This is my understanding.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,151
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1435
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: Building DLLs in VC++

 
0
  #9
Sep 8th, 2005
sounds like the function names in the dll have been mangled, so mathlib doesn't know how to handle that. In the dll, use extern "C" if you don't need c++ classes to keep the compiler from mangling the names.
  1. extern "C"
  2. {
  3. void _dllexport foo();
  4. }

DllMain() is called by the os, not directly by using applications. Its sortof like a c++ class constructor/destructor in that it is called then the DLL is loaded into memory and again just before exit.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 15,976
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 506
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Building DLLs in VC++

 
0
  #10
Sep 16th, 2005
Sorry but I cant figure it out for you as I cant install VC++ 4 on my XP machine as it wants to install IE 1 and says I dont have it. If I click cancel install aborts and I cant just copy the files.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC