Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

static dll linking

92 views
Skip to first unread message

amarok

unread,
Jul 13, 2007, 2:46:36 AM7/13/07
to
I've got a problem - I must to static link to dll library, which is
placed in subdirectory of application.
I knonw how do it in delphi but I don't known how do it in c++
(builder).

In delphi I do:
procedure FunctionName; stdcall; external 'subdirectory\library.dll';

In c++ static linking is making by lib files and there's no path and
file name of dll defined:
void __declspec(dllimport) __stdcall FunctionName();

I dont want to set paths in system and linking dynamic by LoadModule
etc.

Can you help me?

kenn...@gmail.com

unread,
Jul 13, 2007, 4:31:03 PM7/13/07
to
On Jul 13, 1:46 am, amarok <Krzysztof.Piotrow...@gmail.com> wrote:
> I've got a problem - I must to static link to dll library, which is
> placed in subdirectory of application.

A DLL, by definition, uses only dynamic linking. For static linking,
you need a lib file; Delphi neither generates nor uses lib files.

> I knonw how do it in delphi but I don't known how do it in c++
> (builder).
>
> In delphi I do:
> procedure FunctionName; stdcall; external 'subdirectory\library.dll';

That does not do static linking. Did you instead mean to say that you
want to use load-time dynamic linking?

> In c++ static linking is making by lib files and there's no path and
> file name of dll defined:
> void __declspec(dllimport) __stdcall FunctionName();

If the above Delphi declaration works for you, then use that unit in
your C++ Builder project. C++ Builder can use Delphi units.

--
Rob

Rudy Velthuis

unread,
Jul 13, 2007, 8:18:29 PM7/13/07
to
kenn...@gmail.com wrote:

> That does not do static linking. Did you instead mean to say that you
> want to use load-time dynamic linking?

That is also called "static linking" (of a DLL), by many.

> > In c++ static linking is making by lib files and there's no path and
> > file name of dll defined:
> > void __declspec(dllimport) __stdcall FunctionName();

Use the command line tool IMPLIB.EXE that comes with C++Builder. It
will generate an import library for C++Builder.

--
Rudy Velthuis http://rvelthuis.de

"I am ready to meet my Maker. Whether my Maker is prepared for
the great ordeal of meeting me is another matter."
-- Sir Winston Churchill (1874-1965)

Rudy Velthuis

unread,
Jul 13, 2007, 8:18:34 PM7/13/07
to
kenn...@gmail.com wrote:

> On Jul 13, 1:46 am, amarok <Krzysztof.Piotrow...@gmail.com> wrote:
> > I've got a problem - I must to static link to dll library, which is
> > placed in subdirectory of application.
>
> A DLL, by definition, uses only dynamic linking. For static linking,
> you need a lib file; Delphi neither generates nor uses lib files.

There is a confusion of terms/contexts, here.

DLLs are indeed dynamic link libraries, and are therefore linked
dynamically, i.e. at runtime. Linking at compile time is done with .lib
(C/C++) or .dcu(il) (Delphi) files.

But load-time dynamic linking is also called "static linking", since
names are resolved "statically" (and the program will generally not
start if not all names can be resolved), i.e. program code has no
influence on it.

--
Rudy Velthuis http://rvelthuis.de

"Comedy is simply a funny way of being serious."
-- Peter Ustinov (1921-2004)

Jarek Stok?osa

unread,
Jul 16, 2007, 6:00:25 AM7/16/07
to
amarok pisze:
try this:

procedure FunctionName; stdcall; external '.\subdirectory\library.dll';


regards
Jarek

0 new messages