i dont have any code yet because im not sure of the best way to go about doing this.

1. i have multiple dlls that i want to statically link to my program
2. when my program starts i want all the dlls to do their own intialization
3. i do not want to call a function for each statically linked library, for example.. if i have 8 libraries linked i dont want to call 8 seperate functions so they can all do their intialization, i just want to call one.

i have tried doing this before with init and virtual functions from a class after calling new Class and then the virtual function with no luck. maybe i was doing it wrong, i really dont know.. im just confused about the best way to do this and ive tried a ton of things and im almost at the point of giving up.

im not asking anyone to code anything for me, just pointing me in the right direction would do. i appreciate any helpful posts.

Hi. DLL files are dynamically linked to a program. If you want to statically link functions to your program they will probably go in a .lib or .obj file, or in your programs' own .exe file. I believe that linking either static or dynamic libraries is a job for your compiler, so what you need to do will depend on which one you're using. Check the documentation and something should show up.

Steven.

1. you can not statically link a dynamic link library (DLL).
2. The os calls DLL initialization, your program does not do that. Each DLL has a dllMain() function which is similar to main() in C programs. It is called by the os when the dll is first loaded into memory and its job is to do all dll initialization.

3. your program only calls the function it wants to use in the dll. See #2 above.

One thing to keep in mind: all memory allocated in the DLL must be deallocated in the DLL because the memory is allocated in a memory pool that the application program does not know about. And the reverse is true also -- memory allocated by the application program can not be deallocated in a DLL.

thanks for the replies.

based on what you both told me and using google i think i can come up with something, thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.