Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Linking to a static library.

Posted on 2000-04-21
5
Medium Priority
?
348 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 600 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

New feature and membership benefit!

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

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

705 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