Article View: borland.public.cppbuilder.nativeapi
Article #15544Re: how to link a procedure from DLL into EXE code?
From: Wayne A. King
Date: Tue, 24 Jun 2003 18:16
Date: Tue, 24 Jun 2003 18:16
35 lines
2580 bytes
2580 bytes
On Mon, 23 Jun 2003 16:16:33 +0400, "Nitisara" <nitisara@mail.ru> wrote: >Is there a way to link a procedure from DLL into EXE code? >How this can be done? Your question is ambiguous. If you're asking how to *use* a DLL then see the other replies which describe how to implicitly link to the DLL's functions using an import lib (loadtime dynamic linking) and how to explicitly link to the functions using LoadLibrary(), etc. (runtime dynamic linking). If, however, you're asking how to *add* the procedure from a DLL to an EXE you're building, so that the DLL is no longer needed and doesn't have to be distributed with your EXE, then it can't done. To do that you need a *static* library which contains the function to be linked to in obj format. Note that many libraries (including the compiler's RTL) are provided in both dynamic (DLL with associated import LIB) and static (.LIB) versions. Don't make the common mistake of thinking that an import lib is a static lib. The former typically only contains the info needed by the linker to generate code which will load the DLL and reference its exported functions/data. If you link with an import lib, you are dynamically linking to the associated DLL which will always be needed at runtime. By contrast, if you link to a true static lib, the functions' code is actually included into your EXE as a fixed (static) and permanent part of it. Note that there is no way to create a *static* lib from a *dynamic* lib. They have to be prebuilt as static libs. You can only create an import lib from a DLL. -- Wayne A. King (ba994@torfree.net, wayne.king@ablelink.org, waking@idirect.com, Wayne_A_King@compuserve.com)
Technical Details
Message-ID:
<3ef8952c.8680401@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ef6eee3$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,c25cc947ab95860c X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-24 11:23:04 PST From: waking@idirect.com (Wayne A. King) Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: how to link a procedure from DLL into EXE code? Date: Tue, 24 Jun 2003 18:16:08 GMT Message-ID: <3ef8952c.8680401@newsgroups.borland.com> References: <3ef6eee3$1@newsgroups.borland.com> X-Newsreader: Forte Free Agent 1.21/16.243 NNTP-Posting-Host: 216.154.3.244 X-Trace: newsgroups.borland.com 1056478663 216.154.3.244 (24 Jun 2003 11:17:43 -0700) Lines: 35 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail