Solved

Linking to a static library.

Posted on 2000-04-21
5
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 3

Accepted Solution

by:
gaohong earned 200 total points
ID: 2738456
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
ID: 2739531
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
ID: 2740310
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
ID: 2740324
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
ID: 2741328
Adjusted points from 100 to 200
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ get user from AD  (VS6) 7 111
Path to  STL Map header file 1 91
I could not set window to top 4 63
visual C++ 1 43
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

752 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