Author Topic: Using dll created in code blocks in another code blocks project  (Read 7269 times)

Offline AlanSmithee

  • Single posting newcomer
  • *
  • Posts: 2
Using dll created in code blocks in another code blocks project
« 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!

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6894
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline AlanSmithee

  • Single posting newcomer
  • *
  • Posts: 2
Re: Using dll created in code blocks in another code blocks project
« Reply #2 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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6894
    • My Best Post
Re: Using dll created in code blocks in another code blocks project
« Reply #3 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.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Using dll created in code blocks in another code blocks project
« Reply #4 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.