Solved

Linking to a static library.

Posted on 2000-04-21
5
345 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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.

635 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