Author |
Message |
kinghellz Guest
Offline
|
Posted: Sun Oct 07, 2007 9:18 am Post maybe stupid Post subject: how to make a DLL with c++ |
 |
|
|
|
I know C++ up to functions, and i just want to ask can any one tell me how dlls work and how to use them.
My first question, in the exe file do you have to type in like #include code.dll or something like that so that program would use the dll
in the dll do you have to do something like #include helloworld.exe for it to attach the code?
Can any one just write a quick tutorial how to do hello world, like so the exe file would say hello world skip a line, and then code from dll say hello world.(also how to do it in DEV c++)
I searched on google nothing helped me
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Sun Oct 07, 2007 12:25 pm Post maybe stupid Post subject: |
 |
|
|
|
basicly the dll file contains functions implementations (.cpp or .c), and shares a header file (.h) with the executable.
The executable can then lookup functions by name, in the case of dynamic linking anyway. You also need to set certain flags in the compiler so that it knows your compiling a .dll rather than an .exe.
Attached is a simple example of this (using inheritance too, which you can ignore). dlltest is the actual .dll, and dllcaller is the program that calls the dll. _________________ SubSpace Discretion: A Third Generation SubSpace Client
dll!.zip - 848.91 KB
File downloaded or viewed 31 time(s)
|
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sun Oct 07, 2007 6:32 pm Post maybe stupid Post subject: |
 |
|
|
|
Bak's example is of run time linking, which it isn't clear that you need. For static linking (you know which dll to use when you compile it), you should tell your compiler to link against your dll. I don't know the exact settings for dev c++, but if that's what you want then maybe someone else can fill in the missing details. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me
|
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Tue Oct 09, 2007 3:04 pm Post maybe stupid Post subject: |
 |
|
|
|
In Devcpp you can start a new dll project which should come with a template.
Once you have your dll you can link it via project options, parameters, then click on "add library or object". Usually you link to the .a file (gets generated when you compile the dll) but the actual .dll file works too (you'll need to change the filter to all files to see the .dll file). _________________ ss news
|
|
Back to top |
|
 |
|