jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
ok, i'm using dev-c++ to make a DLL for some code. i've been trying to get just a simple demo going but murphy is at it again with his laws. heres the export definition:
heres my class, defined in dll.h:
the dll project compiles fine and life is good on that side, but when i try to call code that is defined in a .cpp file, it hates me. I have read somewhere that you CAN put code in a .cpp file in a DLL so someone please tell me why this is not working. [This message has been edited by jestermax (edited July 18, 2006).] |
|||
SSquared![]() Member Posts: 654 From: Pacific Northwest Registered: 03-22-2005 |
What exactly is the linker error? You are correct. This should not be a problem. Did you do a complete REBUILD of the code? It's quite strange for Hello to work, but not Hello2. As long as they are both public, there should be no problem. I am more familiar with VS.NET, so I can't quite help with dev-c++ configuration. Be sure to check the .lib file/directory your client project is looking at? Is it possible you added Hello2, compiled, and then left the .lib file in some build directory? Do you need to copy the new .lib file to some other location where your client project is actually looking for the .lib file? |
|||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
the client project and the dll project are in the same folder. i always make sure to clean the project files out when i make changes to a program. The compiled DLL is in the same folder and i added that folder to the Library Directories section (the client wouldn't compile without me adding it there). the only difference between Hello() and Hello2() is that Hello2() is in a .cpp file: <BLOCKQUOTE><table width=80% border=0 bgcolor="#FFFFF" CELLPADDING="2" CELLSPACING="2"><TR><TD><font size="3" face="Courier" color="#000000"><pre> void DllClass::Hello2(){ maybe i'll try it with VS 8 tomorrow sometime
Undefined reference to <some compiler jibberish> DllClass6Hello2Env' [This message has been edited by jestermax (edited July 18, 2006).] |
|||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
UGHHHH i just read a posting on this site: http://support.realsoftware.com/listarchives/realbasic-plugins/2005-01/msg00007.html at the bottom the guy says you can't export c++ classes. can someone please tell me whats going on here? it works fine if the code is in the same header file but dies if its in a .cpp file. is this normal? or did i just mess up? |
|||
dartsman![]() Member Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
have a look at: http://www.projectnresource.com/phpbb/viewtopic.php?t=14 main things to check out are that you are actually including the .lib file in your project setting or through #pragma comment(lib, "dllName.lib"), also that you are including the header file which has the "__declspec(dllimport)" of your class... Just sounds like your either not including the .lib file in the project settings or else you don't have the "__declspec(dllimport)" of your class... ------------------ |
|||
dartsman![]() Member Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
oh... lol... Posted within 2 mins of each other, didn't see your last message... if your on msn, give me a buzz at dartsman (at) hotmail.com I could help you out more... I've got my engine which I'm currently working on (classes and all) wrapped up nicely in a dll... working fine too... ------------------ |
|||
dartsman![]() Member Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
argh... again stopped by the whole "service temporarily unavailable" thingo... stupid spam threads, I totally blame them grrr... anywho, check out: http://www.projectnresource.com/phpbb/viewtopic.php?p=627#627 ------------------ |
|||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
YES!!! the flying dartsman figured it out. i was adding the library improperly to the project. i had: -Project.lib when it should be: libProject.a haha, and as i'm writing this post i just realized why it worked if the code was in the header file. The projects were in the same directory and so it was including the header file that already contained the code. So it wasn't even bothering with the DLL. Anyways, it works now and if you're using dev-c++ then thats what you need to do. |