Author Topic: Including DLLs in Code::Blocks projects  (Read 31284 times)

Offline greentiger

  • Single posting newcomer
  • *
  • Posts: 6
Including DLLs in Code::Blocks projects
« on: February 26, 2010, 09:51:34 am »
In the Project build options -> Linker settings -> Add (Link libraries), I find that I can add .a, .so. .lib, .dylib and .bundle files, but not .dlls.

However, compiling a project as a Shared Library genrates a .a, a .def and a .dll file. Now adding the .a file generates "function <> definition marked dllimport" errors from the library I'm trying to compile and use (ARIA). I've tried including the path of the DLL in the search directories also. This error persists.

How can I get a .so from Code::Blocks (on Windows) or include a DLL in a Code::Blocks project?
---

MORE INFO: I searched within this forum a little more intelligently, and found this thread http://forums.codeblocks.org/index.php/topic,10283.0.html to be very close to what I need. I am indeed getting a .a file, as I've already said: but even including it in the project using the library doesn't solve the problem.  :(
« Last Edit: February 26, 2010, 11:22:06 am by greentiger »

Offline greentiger

  • Single posting newcomer
  • *
  • Posts: 6
Re: Including DLLs in Code::Blocks projects
« Reply #1 on: March 01, 2010, 01:07:59 pm »
Am I not clear in stating my problem or has no one used DLLs here? Please let me know if there's anything I need to clarify before you can help me.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Including DLLs in Code::Blocks projects
« Reply #2 on: March 01, 2010, 01:48:55 pm »
I can't get your idea... :( Can you give us steps to reproduce the problem?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline greentiger

  • Single posting newcomer
  • *
  • Posts: 6
Re: Including DLLs in Code::Blocks projects
« Reply #3 on: March 01, 2010, 07:20:30 pm »
There is this library called ARIA ( http://robots.mobilerobots.com/wiki/ARIA ), which I downloaded. They advice us to recompile instead of using the compiled version if we use a different compiler to compile the programs we write using the library functions. I have been able to successfully create (putting their source code in a "Shared library" project in Code::Blocks) a .so file, which I could include in my subsequent programs using the library. I did this because I have a more recent version of GCC than they've used when making their supplied .so file. I have been able to successfully compile and execute these programs too.

However, on Windows, choosing a "Shared library" project and putting in their source code creates a .dll, .a and a .def instead. I have successfully created these three files for the library's source code. However, as I create projects trying to use the Library, the (Project) Build options -> Linker settings -> Add button offers addition only for .a, .lib, .so, .dylib and .bundle files and not .dll files. Merely including the .a in my project and trying to compile it generates "function definition marked dllimport" errors for hundreds of functions in the library. These errors persist when I copy down the .dll in my project folder and in the bin\Debug folder. I've also tried adding the DLL's path in Build options -> Search directory".

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Including DLLs in Code::Blocks projects
« Reply #4 on: March 01, 2010, 10:26:26 pm »
I suggest you read the Library directions on build and using a DLL; sounds like you have defined something wrong either during the DLL Build or the application using the DLL.

Please turn on FULL Compiler Logging and ask the question with build log in the forum that supports building and using the library.
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

NOTE: This web-site DOES NOT support that library.

Edit: I suggest using the same base version of GCC on windows, the latest 3.4.5 from MinGW, and see if their compiled DLL works right with a project. If it does, then likely you are building the DLL wrong.

Tim S.
« Last Edit: March 01, 2010, 10:56:31 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline greentiger

  • Single posting newcomer
  • *
  • Posts: 6
Re: Including DLLs in Code::Blocks projects
« Reply #5 on: March 02, 2010, 02:03:29 am »
Quote
NOTE: This web-site DOES NOT support that library.
Yes, I understand that. I was able to use it all right in Linux, so I think the library itself doesn't have a problem, it's some problem in the way I'm using Code::Blocks on Windows.

Will try your suggestions and tell what happens.

Offline greentiger

  • Single posting newcomer
  • *
  • Posts: 6
Re: Including DLLs in Code::Blocks projects
« Reply #6 on: March 03, 2010, 07:57:38 am »
Simply put, I would like to know the possible causes and corresponding corrections for the error, "function definition marked dllimport".

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Including DLLs in Code::Blocks projects
« Reply #7 on: March 03, 2010, 08:13:18 am »
Simply put, I would like to know the possible causes and corresponding corrections for the error, "function definition marked dllimport".
Did you try:
http://www.google.com/search?q=function%20definition%20marked%20dllimport
???

Notice that this forum does not provide support for general programming questions and / or compiler issues. This forum is related to the development of the Code::Blocks IDE, only.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Including DLLs in Code::Blocks projects
« Reply #8 on: March 03, 2010, 03:26:39 pm »
Please turn on FULL Compiler Logging and ask the question with build log in the forum that supports building and using the library.
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Try posting on the site that supports the library.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org