Go Back   TechArena Community > Technical Support > Computer Help > Windows XP > Windows XP Support
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , ,

Sponsored Links



Dynamically linking with MSVCRT.DLL using Visual C++ 2008 (instead of MSVCR90.DLL)

Windows XP Support


Reply
 
Thread Tools Search this Thread
  #1  
Old 18-02-2010
Viv
 
Posts: n/a
Dynamically linking with MSVCRT.DLL using Visual C++ 2008 (instead of MSVCR90.DLL)

Hi all,

I wrote an application using Visual C++ 2008 that has to be as small
as possible. By using the /MD flag (Multi-threaded) I link dinamycally
with the MSVCR90.DLL which is not by default an all OSs. I would like
to link dinamically with the MSVCRT.DLL because then I won't need to
deploy the DLL as it's by default on every OS starting at least with
Win 2000.

1) I wrote a simple "hello world" application and I did the following
settings:
- Linker -> Input -> Ignore all default Libraries: Yes (/NODEFAULTLIB)
- then b/c I was getting linking errors I also did: Linker -> Command
Line -> Additional Options: msvcrt.lib
Now the app builds, but looking at the final exe with depends.exe I
see that it still depends on the: msvcr90.dll.
Can smbd tell me if this is a "normal" behaviour? I mean to still be
dependant on msvcr90.dll? And how could one actually get rid of the
msvcr90.dll?


2) I also read the article:
http://kobyk.wordpress.com/2007/07/2...visual-c-2005/
but this didn't work for me. Maybe I missed some steps? Can smbd that
actually succeded in doing that write the steps he/she did?

3) Related with the article mentioned above: How can the developers
that use WDK to build their products (eg drivers developers), to
actually run their products in debug mode if there is no where to be
found a msvcrtd.dll?


Thanks in advance,
Viv
Reply With Quote
  #2  
Old 19-02-2010
Wilson, Phil
 
Posts: n/a
Re: Dynamically linking with MSVCRT.DLL using Visual C++ 2008 (instead of MSVCR90.DLL)


As you say, msvcrt.dll has been a standard built-in part of the OS since
Windows 2000, so you shouldn't need to do any static binding to that, and
anyway I'd be surprised if your binary has a direct dependency on
msvcrt.dll. Of course you still depend on msvcr90.dll because that's the CRT
associated with VC 9.0, not msvcrt.dll. You can't get rid of that unless
you can delete all of your CRT references, but I don't know if that's
actually possible.
--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972


"Viv" <vcotirlea@hotmail.com> wrote in message
news:mfaqn59h68gl4652vqlnjr4rggcqea9m3g@4ax.com...
> Hi all,
>
> I wrote an application using Visual C++ 2008 that has to be as small
> as possible. By using the /MD flag (Multi-threaded) I link dinamycally
> with the MSVCR90.DLL which is not by default an all OSs. I would like
> to link dinamically with the MSVCRT.DLL because then I won't need to
> deploy the DLL as it's by default on every OS starting at least with
> Win 2000.
>
> 1) I wrote a simple "hello world" application and I did the following
> settings:
> - Linker -> Input -> Ignore all default Libraries: Yes (/NODEFAULTLIB)
> - then b/c I was getting linking errors I also did: Linker -> Command
> Line -> Additional Options: msvcrt.lib
> Now the app builds, but looking at the final exe with depends.exe I
> see that it still depends on the: msvcr90.dll.
> Can smbd tell me if this is a "normal" behaviour? I mean to still be
> dependant on msvcr90.dll? And how could one actually get rid of the
> msvcr90.dll?
>
>
> 2) I also read the article:
> http://kobyk.wordpress.com/2007/07/2...visual-c-2005/
> but this didn't work for me. Maybe I missed some steps? Can smbd that
> actually succeded in doing that write the steps he/she did?
>
> 3) Related with the article mentioned above: How can the developers
> that use WDK to build their products (eg drivers developers), to
> actually run their products in debug mode if there is no where to be
> found a msvcrtd.dll?
>
>
> Thanks in advance,
> Viv


Reply With Quote
  #3  
Old 19-02-2010
Jonathan Wilson
 
Posts: n/a
Re: Dynamically linking with MSVCRT.DLL using Visual C++ 2008 (insteadof MSVCR90.DLL)

What you ask is not possible, Visual C++ 2008 cannot use MSVCRT.dll as a c
runtime, only MSVCR90.dll
Reply With Quote
  #4  
Old 19-02-2010
David Wilkinson
 
Posts: n/a
Re: Dynamically linking with MSVCRT.DLL using Visual C++ 2008 (insteadof MSVCR90.DLL)

Viv wrote:
> Hi all,
>
> I wrote an application using Visual C++ 2008 that has to be as small
> as possible. By using the /MD flag (Multi-threaded) I link dinamycally
> with the MSVCR90.DLL which is not by default an all OSs. I would like
> to link dinamically with the MSVCRT.DLL because then I won't need to
> deploy the DLL as it's by default on every OS starting at least with
> Win 2000.
>
> 1) I wrote a simple "hello world" application and I did the following
> settings:
> - Linker -> Input -> Ignore all default Libraries: Yes (/NODEFAULTLIB)
> - then b/c I was getting linking errors I also did: Linker -> Command
> Line -> Additional Options: msvcrt.lib
> Now the app builds, but looking at the final exe with depends.exe I
> see that it still depends on the: msvcr90.dll.
> Can smbd tell me if this is a "normal" behaviour? I mean to still be
> dependant on msvcr90.dll? And how could one actually get rid of the
> msvcr90.dll?
>
>
> 2) I also read the article:
> http://kobyk.wordpress.com/2007/07/2...visual-c-2005/
> but this didn't work for me. Maybe I missed some steps? Can smbd that
> actually succeded in doing that write the steps he/she did?
>
> 3) Related with the article mentioned above: How can the developers
> that use WDK to build their products (eg drivers developers), to
> actually run their products in debug mode if there is no where to be
> found a msvcrtd.dll?


You should try static linking (/MT compiler option).

Project Properties->Configuration Properties->C/C++->Code Generation->Runtime
Library

This will most certainly work for your "hello world" application. Whether it can
be done for your actual application depends on what kind of architecture it has.
If you use DLL's, especially 3rd party DLL's, you probably won't be able to use
static linking.

--
David Wilkinson
Visual C++ MVP
Reply With Quote
  #5  
Old 23-02-2010
 
Posts: n/a
Re: Dynamically linking with MSVCRT.DLL using Visual C++ 2008 (instead of MSVCR90.DLL)

Something like this. I don't know if I've used this
with 2008 compiler/libs; I know I have for 2005.
Some things you may have a problem with, like, off
the top of my head, _ftol2 but if you have a small
program and don't care for the rtl, this should do (but
you'll need to figure it out). Oh, I see I mention
ftol2. Posted only because, well, no one else did.
It's trivial - if it links. I think /QIfist or similar
would get rid of the need for _ftol2, but that's not
in (2008's) cl.exe anymore.

#if 1 // use 0 to always use vc7 rtl DLL (testing only)
#ifndef _DEBUG
#ifndef USE_VC8_RTL
// 21-Sep-2002: this is in the non-9x release (won't be released;
to get _ftol2)
#pragma comment(linker, "/NODEFAULTLIB:msvcrt80.lib")
//4-Jan-2003: not here anymore: #pragma comment(lib,
"/vs6/vc6/lib/msvcrt.lib")
///13-Feb-2007: no here: #pragma comment(lib,
"/apps/vs6/vc98/lib/msvcrt.lib")
#pragma comment(lib, "/prj_files/my_lib/vs6/msvcrt.lib")
#else
#ifdef SHOW_RTL_MSG // only show this when in 91_dsp.cpp
#pragma message("using VC8 RTL; USE_VC8_RTL defined")
#endif
#endif
#endif
#else
#pragma mac_MSG(" ********** USING VC8 RTL ************* testing")
#endif

The line wraps were unavoidable.

--
40th Floor - Software @ http://40th.com/
PhantasmX3 - The finest sound in the world
CastleKeeper - IP camera surveillance/recorder
Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows XP > Windows XP Support


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Dynamically linking with MSVCRT.DLL using Visual C++ 2008 (instead of MSVCR90.DLL)"
Thread Thread Starter Forum Replies Last Post
Visual Studio 2010: features and changes compared to Visual Studio 2008 BinDs14 Guides & Tutorials 2 16-02-2011 02:49 PM
Tips of linking the database to form for better the performance in Visual Studio 2010 Candace Tips & Tweaks 1 30-01-2010 03:29 AM
Difference between Visual studio 2005 and Visual studio 2008 RohanS Software Development 3 12-06-2009 11:48 AM
C++ with Visual C++ 2008 avvia Software Development 3 27-02-2009 02:21 PM
What is Visual Studio 2008 Jackie Software Development 1 23-12-2008 05:31 PM


All times are GMT +5.5. The time now is 09:20 AM.