News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Using dll created in code blocks in another code blocks project

Started by AlanSmithee, September 14, 2014, 05:47:20 PM

Previous topic - Next topic

AlanSmithee

Hello!

I have created a minimal dll following this tutorial: http://forum.thegamecreators.com/?m=forum_view&t=167112&b=18

After completion the files "<name>.dll", "lib<name>.a" and "lib<name>.def" are created - So far so good!

Next I tried to use the library in another project by doing the following:

1. Added "<name>.dll" file to the debug folder of the project that wants to use the dll
2. Added "lib<name>.a" to the projects linker settings (Project's build options... -> linker settings -> add relative path to "lib<name>.a" file)
3. Called a function residing in the library from the project that is using the dll
4. Build project

* Expected result: Function is called
* Actual result: 'Cube' was not declared in this scope

Could someone please enlighten me as to what it is that I am doing wrong?
It is af the library cannot be found, but I have included it and linked to it as I would have any other library.

Thanks in advance!

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

AlanSmithee

Thanks!

The problem was that I was not pointing to the source of the dll project (including path to dll source files in compiler settings of project using dll).

I must have missunderstood the use of DLL's because I thought the point was to not have to include the source and that it would be enough to "include" the library and the dll itself?

Do you still need to point to the source (include path in you project) even when using DLL's or have I done something wrong when generating the dll?

Thanks again.

stahta01

Quote from: AlanSmithee on September 14, 2014, 07:49:27 PM
Thanks!

The problem was that I was not pointing to the source of the dll project (including path to dll source files in compiler settings of project using dll).

I must have missunderstood the use of DLL's because I thought the point was to not have to include the source and that it would be enough to "include" the library and the dll itself?

Do you still need to point to the source (include path in you project) even when using DLL's or have I done something wrong when generating the dll?

Thanks again.

You likely did something wrong; no idea if you did or did not.

Without the build log; I have no idea what your problem was or is now.

You NEED to have the headers and either the DLL or export library visible to the client code using the DLL.

Tim S.

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

scarphin

As far as I know one has to point to the declarations of the functions stacked in the dll to introduce them to the compiler.