Code::Blocks Forums

User forums => Help => Topic started by: AlanSmithee on September 14, 2014, 05:47:20 pm

Title: Using dll created in code blocks in another code blocks project
Post by: AlanSmithee on September 14, 2014, 05:47:20 pm
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!
Title: Re: Using dll created in code blocks in another code blocks project
Post by: stahta01 on September 14, 2014, 06:01:52 pm
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
Title: Re: Using dll created in code blocks in another code blocks project
Post by: 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.
Title: Re: Using dll created in code blocks in another code blocks project
Post by: stahta01 on September 14, 2014, 07:54:03 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.

Title: Re: Using dll created in code blocks in another code blocks project
Post by: scarphin on September 14, 2014, 09:09:08 pm
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.