Skip to main content
GameDev.net gamedev.net
🔒 Locked

easy DLL question

Started by bjut Sep 13, 2005 at 6:43 AM 6 replies 750+ views
Original Post
bjut
bjut
hello! I'm trying to make a DLL which uses some functions in other LIB files and DLLs. When I try to register it using regsvr32, I get a failed message unless I also put the other DLLs that I used in the same directory as the DLL that I'm trying to register. If I am to use my DLL as a plug-in to another application, then I would also need to register the other DLLs, right? Is there a way to permanently import the functions that I used into my DLL so that I wouldn't have to register so many of the other DLLs? By the way, I'm using Visual C++ .NET 2003. Thanks!!
moeron
moeron
If that is what you want to do then just use static library links. You completely abandon the advantages of a DLL by importing all the functions at compile time. Keep in mind, however, if any of those libraries ever need to change then you must recompile everything that uses it (this is the exact problem that dlls were made to fix!)

hth,
moe.ron
moe.ron
UltimaX
UltimaX
If you're designing a DLL as a plugin then you should be able to drop it into the plugin directory and that is it. You shouldn't have to register it at all.
The program that is using the plugin should automatically recognize the DLL and take the appropriate action to handle that DLL.

Try using the GetProcAddress(*) function to call the functions inside of the DLL.
bjut
bjut
thanks guys!

yup you're right about that! DLLs are supposed to be "dynamic". The reason why I wanted to statically link the other DLLs with my DLL is because the application that I'm trying to make a plugin for says that it can't load the DLL. So I have to test whether it's because of dependency issues or because of my code. I already put some MessageBox's in the initialization methods and they didn't come up before the application gave an error so it might be due to dependency issues. Just to make sure, I'd like to statically link them to my DLL if possible and see if it would pass through my initialization codes.

How do you statically link them anyway?
moeron
moeron
Your going to have to either a.) create a new project that is setup to create a static library (.lib) or b.)change your current project (which would just be messy)

There is no way that I know of to statically link to a dynamic library directly.
moe.ron
bjut
bjut
hey thanks for the replies!

forgot about this post coz I didn't have the email notification "ON". anyway you're right. I'm using a 3rd party SDK and I only have the headers, LIB, ang DLLs. So I guess static linking is out of the question since the LIB files don't seem to have the source in them. thanks for making that clear, moeron.

It's also too bad that I wasn't able to read this post sooner. The LoadLibrary error message was due to not being able to find the other DLLs that my plug-in was referencing. You were right. I just put the other DLLs in the same path of the plug-in when registering it using regsvr32 and it went fine. The other error that said that the app couldn't load my plug-in was due to an older version of the DLL that I'm using being loaded first by the app. This is because some other plug-in that came with the app also uses the same SDK and DLL but older. I just replaced that DLL with a newer version that came with the SDK.

Thanks a lot and keep it up!
ldeej
ldeej
BTW - regsvr32 is only used for registering COM components. If your application or the library you are using are not implemented as COM components then you have no need to call regsvr32.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.