Solved

Linking to a static library.

Posted on 2000-04-21
5
339 Views
Last Modified: 2010-04-10
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
Comment
Question by:Yo081699
  • 3
5 Comments
 
LVL 3

Accepted Solution

by:
gaohong earned 200 total points
Comment Utility
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
 
LVL 3

Expert Comment

by:ufolk123
Comment Utility
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
 

Author Comment

by:Yo081699
Comment Utility
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
 

Author Comment

by:Yo081699
Comment Utility
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
 

Author Comment

by:Yo081699
Comment Utility
Adjusted points from 100 to 200
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now