Discussion:
How to write a pure C program independ on msvcr90.dll
(too old to reply)
Joe.M
2008-06-19 03:34:15 UTC
Permalink
Hi, all,

I want to write a pure c program that independ on msvcr90.dll, can I
do this with Visual Studio 2008?

This idea based on I do not want to deploy msvcr90.dll to target
machine just for a small toolkit program. If I can do this, all I need
to do is to copy the program to target machine because that toolkit
program just depends on Windows system dlls. And I do not want to
static link to msvcr90.dll.


Thanks.
Brian Muth
2008-06-19 03:48:09 UTC
Permalink
Post by Joe.M
Hi, all,
I want to write a pure c program that independ on msvcr90.dll, can I
do this with Visual Studio 2008?
This idea based on I do not want to deploy msvcr90.dll to target
machine just for a small toolkit program. If I can do this, all I need
to do is to copy the program to target machine because that toolkit
program just depends on Windows system dlls. And I do not want to
static link to msvcr90.dll.
If you say you want to remove the dependency on msvcr90.dll and not statically link (I won't question you on why these are your
requirements) then you have to remove all calls to the run time library.

See if this article gives you ideas: http://www.ddj.com/windows/184416623

It's a bit old, but the principles still hold.

Brian
Joe.M
2008-06-19 04:59:41 UTC
Permalink
Post by Brian Muth
Post by Joe.M
Hi, all,
I want to write a pure c program that independ on msvcr90.dll, can I
do this with Visual Studio 2008?
This idea based on I do not want to deploy msvcr90.dll to target
machine just for a small toolkit program. If I can do this, all I need
to do is to copy the program to target machine because that toolkit
program just depends on Windows system dlls. And I do not want to
static link to msvcr90.dll.
If you say you want to remove the dependency on msvcr90.dll and not statically link (I won't question you on why these are your
requirements) then you have to remove all calls to the run time library.
See if this article gives you ideas:http://www.ddj.com/windows/184416623
It's a bit old, but the principles still hold.
Brian
Thank you for your reply.

The article is good, I'll study it now.
Carl Daniel [VC++ MVP]
2008-06-19 04:12:52 UTC
Permalink
Post by Joe.M
Hi, all,
I want to write a pure c program that independ on msvcr90.dll, can I
do this with Visual Studio 2008?
This idea based on I do not want to deploy msvcr90.dll to target
machine just for a small toolkit program. If I can do this, all I need
to do is to copy the program to target machine because that toolkit
program just depends on Windows system dlls. And I do not want to
static link to msvcr90.dll.
I think you're mixing up your terms.

You never statically link to a DLL - using an import library for a DLL is
the exact opposite of static linking.

If you don't want a dependency on MSVCR*.DLL, then compile using /MT and
link against libcmt.lib (which will be the default library if you've
compiled with /MT).

-cd
Joe.M
2008-06-19 05:01:11 UTC
Permalink
On Jun 19, 12:12 pm, "Carl Daniel [VC++ MVP]"
Post by Carl Daniel [VC++ MVP]
Post by Joe.M
Hi, all,
I want to write a pure c program that independ on msvcr90.dll, can I
do this with Visual Studio 2008?
This idea based on I do not want to deploy msvcr90.dll to target
machine just for a small toolkit program. If I can do this, all I need
to do is to copy the program to target machine because that toolkit
program just depends on Windows system dlls. And I do not want to
static link to msvcr90.dll.
I think you're mixing up your terms.
You never statically link to a DLL - using an import library for a DLL is
the exact opposite of static linking.
If you don't want a dependency on MSVCR*.DLL, then compile using /MT and
link against libcmt.lib (which will be the default library if you've
compiled with /MT).
-cd
Thank you for your help.

You are right, the /MT compile option solved my problem. Thanks.
Alex Blekhman
2008-06-19 05:05:16 UTC
Permalink
Post by Joe.M
I want to write a pure c program that independ on msvcr90.dll,
can I do this with Visual Studio 2008?
In addition to the Brian's post, here are another examples of
elimination CRT:

"Reduce EXE and DLL Size with LIBCTINY.LIB"
http://msdn.microsoft.com/en-us/magazine/cc301696.aspx

"Tiny C Runtime Library"
http://www.codeproject.com/KB/library/tlibc.aspx

However, I am in doubt that this approach is worth the effort.
Dveloping without the CRT is a painfull, error prone task. Why
don't you want to link with CRT statically?

Alex
Joe.M
2008-06-19 05:33:18 UTC
Permalink
Post by Alex Blekhman
Post by Joe.M
I want to write a pure c program that independ on msvcr90.dll,
can I do this with Visual Studio 2008?
In addition to the Brian's post, here are another examples of
"Reduce EXE and DLL Size with LIBCTINY.LIB"http://msdn.microsoft.com/en-us/magazine/cc301696.aspx
"Tiny C Runtime Library"http://www.codeproject.com/KB/library/tlibc.aspx
However, I am in doubt that this approach is worth the effort.
Dveloping without the CRT is a painfull, error prone task. Why
don't you want to link with CRT statically?
Alex
Hi, Alex,

I just want to smaller program and has no other dependencies expect
Windows system dlls. Use /MT option you can link to static version of
c run-time library: libcmt.lib, then you can copy your program to
target machine and run it.

Joe.M
s***@gmail.com
2008-06-20 14:06:35 UTC
Permalink
Does Borland or Bloodshed compliers compile to a purely stand-alone
applications?
Hendrik Schober
2008-06-20 15:46:50 UTC
Permalink
Post by s***@gmail.com
Does Borland or Bloodshed compliers compile to a purely stand-alone
applications?
Borland does (and you have to decide whether to link to
the static or dynamic RTL, too). Bloodshed is, IIRC, just
an IDE, so it doesn't compile at all.

HTH,

Schobi
s***@gmail.com
2008-06-21 14:19:31 UTC
Permalink
Post by Hendrik Schober
Borland does (and you have to decide whether to link to
the static or dynamic RTL, too).
Libraries used by users are required to be deployed but you mean
dependencies such as MSCRT*.DLLs (this is for MSVC but anything like
this for Borland) are not for exe produced by Borland, right?
Post by Hendrik Schober
Bloodshed is, IIRC, just
an IDE, so it doesn't compile at all.
Excuse me, but IIRC means? So if Bloodshed is just an IDE, then its
core complier is from? I hear Bloodshed is famous among virus writers
and virus writes have a major requirement of their exe not depending
on compliers added DLLs.
Hendrik Schober
2008-06-22 00:21:16 UTC
Permalink
Post by s***@gmail.com
Post by Hendrik Schober
Borland does (and you have to decide whether to link to
the static or dynamic RTL, too).
Libraries used by users are required to be deployed but you mean
dependencies such as MSCRT*.DLLs (this is for MSVC but anything like
this for Borland) are not for exe produced by Borland, right?
Borland's RTL also comes as static lib or as DLL and you
have to decide which one you want to link against. Just
as for VC, this also has further implications (don't link
executables that call each other's C++ APIs while using
different flavours of the RTL) and there also is the
headache of deploying all the necessary DLLs etc. -- only
you can't assume everyone will have their RTL installed
as with VC.
(Take all this with a grain of salt. I haven't done any
real work with a Borland compiler for almost a decade.)
Post by s***@gmail.com
Post by Hendrik Schober
Bloodshed is, IIRC, just
an IDE, so it doesn't compile at all.
Excuse me, but IIRC means?
2nd hit on google: http://acronyms.thefreedictionary.com/IIRC
Post by s***@gmail.com
So if Bloodshed is just an IDE, then its
core complier is from? [...]
1st hit for "bloodshed c++": http://www.bloodshed.net/devcpp.html
"Bloodshed Dev-C++ is a full-featured Integrated Development
Environment (IDE) for the C/C++ programming language. It uses
Mingw port of GCC (GNU Compiler Collection) as it's compiler.
Dev-C++ can also be used in combination with Cygwin or any
other GCC based compiler."

HTH,

Schobi
--
***@gmx.de is never read
I'm HSchober at gmx dot de
"I guess at some point idealism meets human nature and
explodes." Daniel Orner
Loading...