Author Topic: Linking to DLL's  (Read 11534 times)

Offline gregwarner

  • Single posting newcomer
  • *
  • Posts: 3
Linking to DLL's
« on: September 09, 2011, 07:40:14 pm »
Feeling really dumb... How do I link my project to a Windows DLL? (C:\Windows\System32\wiaaut.dll specifically.) I'm at the Linker Settings and I'm trying to add a Link library, but the dialog box only filters file type extensions of .a, .so, .lib, .dylib, and .bundle. How do I choose a DLL?

I have zero experience using Code::Blocks and this is my first time migrating to this IDE.

zabzonk

  • Guest
Re: Linking to DLL's
« Reply #1 on: September 09, 2011, 08:24:02 pm »
You can't link to a DLL directly - you need an import library (a  .LIB file) for it. If you haven't got one, you have to load the functions you want dynamically using LoadLibrary and GetProcAddress. This has nothing specifically to do with Code::Blocks, it's how the Windows linking process works.

« Last Edit: September 09, 2011, 08:25:41 pm by Neil Butterworth »

Offline gregwarner

  • Single posting newcomer
  • *
  • Posts: 3
Re: Linking to DLL's
« Reply #2 on: September 09, 2011, 08:46:18 pm »
Ah. Thank you for clearing that up.

I don't suppose you know where I could find a good tutorial on how to do that, do you?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Linking to DLL's
« Reply #3 on: September 09, 2011, 08:49:26 pm »
FYI:

The answer to your question depends on your Compiler.

NOTE: MinGW GCC can link directly to an DLL.

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

Offline gregwarner

  • Single posting newcomer
  • *
  • Posts: 3
Re: Linking to DLL's
« Reply #4 on: September 09, 2011, 08:56:52 pm »
I'm using the GNU GCC Compiler.

EDIT: I just read that GCC doesn't directly support Microsoft DLL's, so I just downloaded and installed MinGW.

I'm still a little fuzzy on what I need to do next. I know I need to generate an import library if I don't already have one, but where do I check if there already exists an import library for wiaaut.dll?
« Last Edit: September 09, 2011, 09:14:49 pm by gregwarner »

zabzonk

  • Guest
Re: Linking to DLL's
« Reply #5 on: September 09, 2011, 11:20:30 pm »
> NOTE: MinGW GCC can link directly to an DLL.

Saying something "can" do something without providing any idea how is particularly useless.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Linking to DLL's
« Reply #6 on: September 09, 2011, 11:43:59 pm »
> NOTE: MinGW GCC can link directly to an DLL.

Saying something "can" do something without providing any idea how is particularly useless.


FYI: There is this thing called Google.

Note: It is also mentioned in this site many times and there is an example linking to the codeblocks dll in the wiki.

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

zabzonk

  • Guest
Re: Linking to DLL's
« Reply #7 on: September 10, 2011, 12:09:30 am »
I did Google for it and couldn't find anything. But as you obviously know so  many links on to how to do this, would it be asking too much for you to actually post one?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
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