Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

Linking to a static library.

My problem boils down to this one:
Is there anyway to link to a dll/ocx statically?
So that the code of the function linked to is included in my exe.
(On the other hand : link dynamically to a lib?)
If it's impossible, why ?!
0
Yo081699
Asked:
Yo081699
  • 3
1 Solution
 
gaohongCommented:
Yo,

Yes, it is possible.  Under both
VC++/BC++, maybe event C++Builder
there is utility called. implib
which converts dll into lib stub
that your linker links to.  

You have to add .lib files to your
project.
0
 
ufolk123Commented:
For qaohong :

implib is used only to create the import library for a DLL..ie the lib file generated is not the static version of DLL but just the directory kind of thing which you will link in your code to access the functions in the DLL.Keep it if you delete the DLL you will get a run -time error so DLL is not replaced or changed or statically linked.

For Yo:
Hi ,
There is no way to statically link a DLL one of the main eason for this is
How will you justify the Dllmain() wihch is the entry point of DLL.How will you run it if dll is linked statically ?


So better generate a static library from the source code used to build DLL.
0
 
Yo081699Author Commented:
Before rejecting qaohong's answer I'd like to know : In what case can this stub library be useful?
If you could give me an  example...
0
 
Yo081699Author Commented:
ufolk123:
DllMain is there to accomplish some initialization task on the module. If I link statically, I mean include the code into my application, there is no more need for module state management and therefore for the DllMain entry point.

I think that the information that is lost in the dll is all the relocation data that is present in obj files.(In lib too?)

I don't exactly know what is the lib file generated by implib, so I cannot tell if I can use it...
That's why I'm asking for further information about the lib generated by this tool.
0
 
Yo081699Author Commented:
Adjusted points from 100 to 200
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now