From: Dilip on
I am in the process of writing a tiny MFC application (developed on
Visual Studio 2008) that (for reasons that are too confusing to list)
cannot rely on the appropriate redistributables present on the target
machine. I cannot do the obvious thing of shipping the
redistributables along with application. Please lets not get into the
why of it because I am stuck in a weird situation.

As a result my only option is statically link against everything. To
that end my application statically links against MFC. So far so
good. However, I also use a lot of standard C++ features (including
stuff from tr1). I understand at run time my application is going to
go looking for msvcr90.dll and msvcp90.dll, correct? How do I
statically link against CRT and Std C++ libraries? I gather their
static counterparts are libcmt.lib and libcpmt.lib, right? Is it just
a question of putting these in the linker settings?

How can I achieve my objective?
From: Scott McPhillips [MVP] on
"Dilip" <rdilipk(a)lycos.com> wrote in message
news:844504f4-154f-4227-a0ad-d522df5d4f38(a)g10g2000yqh.googlegroups.com...
>I am in the process of writing a tiny MFC application (developed on
> Visual Studio 2008) that (for reasons that are too confusing to list)
> cannot rely on the appropriate redistributables present on the target
> machine. I cannot do the obvious thing of shipping the
> redistributables along with application. Please lets not get into the
> why of it because I am stuck in a weird situation.
>
> As a result my only option is statically link against everything. To
> that end my application statically links against MFC. So far so
> good. However, I also use a lot of standard C++ features (including
> stuff from tr1). I understand at run time my application is going to
> go looking for msvcr90.dll and msvcp90.dll, correct? How do I
> statically link against CRT and Std C++ libraries? I gather their
> static counterparts are libcmt.lib and libcpmt.lib, right? Is it just
> a question of putting these in the linker settings?
>
> How can I achieve my objective?

The setting to statically link to the runtime is in Project, Properties,
C/C++, Code Generation, Runtime Library.

--
Scott McPhillips [VC++ MVP]

From: Alex Blekhman on
On 09-Apr-10 4:08, Dilip wrote:
> I cannot do the obvious thing of shipping the
> redistributables along with application. Please lets not get into the
> why of it because I am stuck in a weird situation.

In addition to Scott's answer. Shipping the redistributables is not so
obvious anymore (and never been for that matter). Sometimes you need to
deliver small tool or package, which should be as independent of
surrounding environment as possible. No installation, no dependencies.
Lately, with all this manifest thing, delivering of an application no
matter how small suddenly became less than trivial. With modern cheap
and huge disks static linking became popular once again.

Alex
From: Martin B. on
Alex Blekhman wrote:
> On 09-Apr-10 4:08, Dilip wrote:
>> I cannot do the obvious thing of shipping the
>> redistributables along with application. Please lets not get into the
>> why of it because I am stuck in a weird situation.
>
> (...) which should be as independent of
> surrounding environment as possible. No installation, no dependencies.
> Lately, with all this manifest thing, delivering of an application no
> matter how small suddenly became less than trivial. With modern cheap
> and huge disks static linking became popular once again.
>

Correct me if I'm wrong, but isn't statically vs. dynamically linking
also a memory issue? (Not for the single tiny app, but for the overall
system)
When "all" small Tools and Services on the system use the DLL runtime
library this DLL only has to be loaded into RAM once, right? However, if
"all" stuff uses static linking, all the rt code has to be loaded
multiple times?

cheers,
Martin
From: Dilip on
On Apr 9, 2:59 am, Alex Blekhman <tkfx.REM...(a)yahoo.com> wrote:
> On 09-Apr-10 4:08, Dilip wrote:
>
> > I cannot do the obvious thing of shipping the
> > redistributables along with application.  Please lets not get into the
> > why of it because I am stuck in a weird situation.
>
> In addition to Scott's answer. Shipping the redistributables is not so
> obvious anymore (and never been for that matter). Sometimes you need to
> deliver small tool or package, which should be as independent of
> surrounding environment as possible. No installation, no dependencies.
> Lately, with all this manifest thing, delivering of an application no
> matter how small suddenly became less than trivial. With modern cheap
> and huge disks static linking became popular once again.

Alex
That is *exacty* my situation. Although I worked with C++/VC++ for
most of the 90s, working in the .NET world for the past several years
have made me forget some routine things in the VS properties dialog.
I am glad to know its not so weird anymore to distribute statically
linked apps.

Thanks!