473,714 Members | 2,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's static link at runtime?

When I build boost libs,
I realized that there is static link at runtime..

What does that mean?

I thought static linking is done at compile time.
Am I wrong?
Jul 22 '05 #1
7 4381
BekTek wrote:
When I build boost libs,
I realized that there is static link at runtime..

What does that mean?

I thought static linking is done at compile time.
Am I wrong?


<warning value="platform specific">
Uh, all platforms I know support this feature,
but C++ itself does not define it, so YMMV.

You can build a library to link statically, as a LIB,
or dynamically, as DLL. The former links at link
time, and the latter links after you double-click on
an executable but before any of the executable's
opcodes evaluate.
</warning>

Many libraries provide both LIBs and DLLs, so the end-programmer can pick if
they want executables that are easy to install or small, respectively.
However <deep breath> The C++ Standard does not define LIBs or DLLs (or .a
and .so files), so future discussions about them belong on any newsgroup
except this one.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces
Jul 22 '05 #2
On Tue, 19 Oct 2004 22:24:48 GMT, "BekTek" <be****@gmail.c om> wrote:
When I build boost libs,
I realized that there is static link at runtime.

What does that mean?

I thought static linking is done at compile time.
Am I wrong?


....

There's coding time.

There's compile time.

There's link time.

There's load time.

There's run time.

On various systems you can get linkages resolved on at least the last
three times, depending on just what kind of components are involved.
There's not a lot of linking as such as compile time, that's why you
have header files and typelibs and whatnot.

J.
Jul 22 '05 #3

"JXStern" <JX************ **@gte.net> schrieb im Newsbeitrag
news:4g******** *************** *********@4ax.c om...
On Tue, 19 Oct 2004 22:24:48 GMT, "BekTek" <be****@gmail.c om> wrote:
When I build boost libs,
I realized that there is static link at runtime.

What does that mean?

I thought static linking is done at compile time.
Am I wrong?


...

There's coding time.

There's compile time.

There's link time.

There's load time.

There's run time.

On various systems you can get linkages resolved on at least the last
three times, depending on just what kind of components are involved.
There's not a lot of linking as such as compile time, that's why you
have header files and typelibs and whatnot.


Windows supports even to resolve at runtime, as the loader supports a
"DELAY_LOAD ", which causes the dynamic library being loaded, when the 1st
function call to it is invoked.

(Or you can control library loading manually of course.)
Regards
Michael
Jul 22 '05 #4
BekTek posted:
When I build boost libs,
I realized that there is static link at runtime..

What does that mean?

I thought static linking is done at compile time.
Am I wrong?


Consider the C++ Standard Library; When you compile a Win32 program, you've
the choice to link with it statically or dynamically. If you analyze the two
different executables, here's what you see:

Statically:

Bigger executable.
When opened in dependency walker, it shows no more dependancies than the
ones you yourself use in the program.

Dynamically:

Smaller executable.
When opened in dependancy walker, it shows a dependancy, a file called
something like "MSVCRUN.DL L". So when you use a Standard C++ Library
function, it's calling it from this DLL file. Here comes a bit of a paradox
now. Even though I'm saying that this is "dynamic" linking; in the world of
Win32, it's actually referred to as "static" linkage. What's referred to as
"dynamic" linkage in Win32 programs is achieved as follows:

HMODULE hDLL = LoadLibrary("na me.dll");

It's all relative!
-JKop
Jul 22 '05 #5

"Phlip" <ph*******@yaho o.com> wrote in message
news:Dx******** **********@news svr19.news.prod igy.com...
BekTek wrote:
You can build a library to link statically, as a LIB,
or dynamically, as DLL. The former links at link
time, and the latter links after you double-click on
an executable but before any of the executable's
opcodes evaluate.
</warning>


I don't know about you, but when I use a DLL, I often explicitly load it in
run-time code, then get the address of the function I need to call, then
call the function. Saying that it links "before any of the executable's
opcodes evaluates" doesn't sound correct to me. Wouldn't it have to wait
until I make the call to load it? (Otherwise, whatever would the call to
load it be doing?)

-Howard
Jul 22 '05 #6
In message <Mi************ ******@bgtnsc05-news.ops.worldn et.att.net>,
Howard <al*****@hotmai l.com> writes

"Phlip" <ph*******@yaho o.com> wrote in message
news:Dx******* ***********@new ssvr19.news.pro digy.com...
You can build a library to link statically, as a LIB,
or dynamically, as DLL. The former links at link
time, and the latter links after you double-click on
an executable but before any of the executable's
opcodes evaluate.
I don't know about you, but when I use a DLL, I often explicitly load it in
run-time code, then get the address of the function I need to call, then
call the function. Saying that it links "before any of the executable's
opcodes evaluates" doesn't sound correct to me.


In that case, it wouldn't be. But many of the static LIBs you link
against are merely tables of contents for the corresponding DLLs, and
*those* DLLs get loaded automatically as described above.
Wouldn't it have to wait
until I make the call to load it? (Otherwise, whatever would the call to
load it be doing?)


--
Richard Herring
Jul 22 '05 #7

"Howard" <al*****@hotmai l.com> schrieb im Newsbeitrag
news:Mi******** **********@bgtn sc05-news.ops.worldn et.att.net...

"Phlip" <ph*******@yaho o.com> wrote in message
news:Dx******** **********@news svr19.news.prod igy.com...
BekTek wrote:
You can build a library to link statically, as a LIB,
or dynamically, as DLL. The former links at link
time, and the latter links after you double-click on
an executable but before any of the executable's
opcodes evaluate.
</warning>


I don't know about you, but when I use a DLL, I often explicitly load it

in run-time code, then get the address of the function I need to call, then
call the function. Saying that it links "before any of the executable's
opcodes evaluates" doesn't sound correct to me.
But loading a DLL "manually" is a different way then linking the DLL, which
means entering all used symbols to the Import Address Table of the
executable, which is used by the loader later on.

In a typical windows application no code from within the executable is
executed before all (linked) DLLs are loaded, because the loader will load
all DLLs before it starts to execute the entry point (typically CRT main,
which does the initialisation and calls your int main() afterwards). But as
windows DLLs have a main (entry point) as well (which is e.g executed when
the dll is loaded), someone could execute code located in the executable
from such a dllmain(). To achieve this you need to know what to execute, so
the executable need to export symbols, which can be found from other modules
(DLLs), which means you can call a GetProcAddress( ...) and get the address
of the exported symbol.
In such cases code from within the executable is executed before all linked
DLLs are loaded.

If you think this sounds very constructed, well there are executables out
there, which do exactly this, but
I have no idea why ;-)

Wouldn't it have to wait
until I make the call to load it? (Otherwise, whatever would the call to
load it be doing?)


If you are using LoadLibrary() everything is under your control and you are
responsible for providing valid function addresses before you call them.
Regards
Michael
Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2528
by: John S Dalzell | last post by:
Hi, I have a C++ app which needs to work with a server on a remote machine. The manufacturer has given us a set of DLL's which provide API calls to send requests to the server and receive an information feed from it. My app is compiled under Micro$oft VS.NET 2003 with option /MT to statically link in the C runtime libraries msvcrt.lib etc. My app has to store information from the server and answer requests from many remote clients. These...
9
2821
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am facing. Please please help me to solve this as soon as possible. So here we go ... I am not able to take the screen shot of the windows form based "Smart
1
1109
by: Bruno van Dooren | last post by:
Hi, i am using a third party static library (.lib) that wraps a class interface around an old C-style dll. in the static library they use the STL for some stuff i don't know about. in my own code, i also use the STL, for basic_string for example. at link time, i get a lot of errors like: msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: __thiscall
3
1387
by: shu | last post by:
I get a _CrtIsValidHeapPointer assertion when trying to have a unmanaged static object linked to my managed project. I have tried to reduce the problem to a very simple case: One unmanaged .cpp file (compiled with "No Common language Runtime Support") added to a managed .exe project. This unmanaged .cpp declares a static object, with its constructor and destructor.
2
2104
by: bonk | last post by:
Hello, I am currently trying to wrap my head around what actually happens when I compile a normal (native) c++ class with the /CLR Flag in Visual C++ 2005 (C++/CLI). Suppose I have the following class deklared in c++: // #pragma managed or #pragma unmanaged // does not seem to make any differnce here
4
1973
by: hack_tick | last post by:
Hi Guys! Is function overloading a kind of static polymorphism?
18
3859
by: Seigfried | last post by:
I have to write a paper about object oriented programming and I'm doing some reading to make sure I understand it. In a book I'm reading, however, polymorphism is defined as: "the ability of two different objects to respond to the same request message in their own unique way" I thought that it was: "the ability of same object to respond to different messages in
669
25997
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
5
6776
by: Jesper Schmidt | last post by:
When does CLR performs initialization of static variables in a class library? (1) when the class library is loaded (2) when a static variable is first referenced (3) when... It seems that (1) holds for unmanaged C++ code, but not for managed code. I have class library with both managed and unmanaged static variables that are not referenced by any part of the program. All the
0
8796
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8704
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9009
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3155
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2514
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2105
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.