Server Help

Trash Talk - how to make a DLL with c++

Anonymous - Sun Oct 07, 2007 9:18 am
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
Bak - Sun Oct 07, 2007 12:25 pm
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.
Dr Brain - Sun Oct 07, 2007 6:32 pm
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.
Smong - Tue Oct 09, 2007 3:04 pm
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).
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group