473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 4334
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.com> 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.com...
On Tue, 19 Oct 2004 22:24:48 GMT, "BekTek" <be****@gmail.com> 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.DLL". 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("name.dll");

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

"Phlip" <ph*******@yahoo.com> wrote in message
news:Dx******************@newssvr19.news.prodigy.c om...
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.worldnet.att.net>,
Howard <al*****@hotmail.com> writes

"Phlip" <ph*******@yahoo.com> wrote in message
news:Dx******************@newssvr19.news.prodigy. 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*****@hotmail.com> schrieb im Newsbeitrag
news:Mi******************@bgtnsc05-news.ops.worldnet.att.net...

"Phlip" <ph*******@yahoo.com> wrote in message
news:Dx******************@newssvr19.news.prodigy.c om...
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
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...
9
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...
1
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...
3
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...
2
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...
4
by: hack_tick | last post by:
Hi Guys! Is function overloading a kind of static polymorphism?
18
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...
669
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...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.