DLL question

Ok so i've been thinking about creating a simple DLL just for fun, I believe It's a file that contains re usable code like a string search algorithm or something like that. So they are basically like functions in C++ except they are separate files that can be used with your other programs right?


I looked up some code for some to see what its like and I seen they used Win32 API, do I need to use win32 API code to create one? I hate w32 API so much I really dont want to work with it at all.
Last edited on
No you don't need to know WINAPI to make a dll. dll's however, are a windows specific file, so its not unusual to have some WINAPI in them.
Last edited on
Ok so I just made a DLL, but how do i use it? I created another project and therefore exe, copied the dll into the project folder with the new exe. Do I have to have the code for the DLL? or is there some way to call it?

I deleted all Winapi code from the DLL template in Code Blocks, and just put a function called Calculate() in it with a output message "Test".
Last edited on
You need language extension dllimport/dllexport. See:

http://wiki.tcl.tk/8721
You need to link to the dll there are two ways to do this. Run time dynamic linking and load time dynamic linking.

Load time dynamic linking
you need to tell codeblocks where to find the .h files.
click project
build options
search directories
then make sure the compiler tab is selected
click the add button and point to the dll project.


now you need to add an import library normally this would be a .lib file with the same name as your dll project (mydllproject.lib), but on codeblocks it will be a .a file.

click project
build options
search directories
then make sure the linker tab is selected.
click the add button and point to the debug/release folder of your dll project
this is the same place where you found the dll itself.
Also not the .a file should be in here.


to link to the import library
click project
build options
select the linker settings tab
click add
and type the name of the .a file

you should now be able to use the code from the dll file the same way you would use any other code. include the file and call the function.
ok, I got it working thanks!
Topic archived. No new replies allowed.