Re: C++\CLI Compiler /nostdlib option?

Trey Nash <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <003c01c6d20c$c2fd0480$8100a8c0@tbone>
Well, let me preface this by saying that you can learn a lot by looking at
the build environment in the WDK.  The makefiles are more or less yanked
directly from the internal build solution that the Windows team uses.

A cursory glance through the makefile reveals the following:

! if "$(URT_VER)" >= "2.0"
MANAGED_CXX_FLAGS=$(MANAGED_CXX_FLAGS) /d1clr:nostdlib /d1clr:nomscorlib
$(USECXX_FLAG)
! Endif

d1clr?!?!  What's that?  I can't find any documentation for this
command-line switch.  So, I slapped together the following c++ file in
test.cpp:

---------------------------------------
#include <iostream>

using namespace std;

void main()
{
    cout << "Hello World!" << endl;
}
---------------------------------------

When I compile it with the following, it works fine:

cl /clr test.cpp

However, throw in the magic compiler switch, and look what happens:

----------------------------------------
C:\Temp>cl /clr /d1clr:nomscorlib test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.42
for Microsoft (R) .NET Framework version 2.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
predefined C++ types (compiler internal)(12) : fatal error C1190: managed
targeted code requires a '/clr' option
----------------------------------------

Notice, that when you pass a known bad command-line param as in the
following, you get something completely different:

----------------------------------------
C:\Temp>cl /clr /foobar:nomscorlib test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.42
for Microsoft (R) .NET Framework version 2.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option
'/foobar:nomscorlib'
test.cpp
Microsoft (R) Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj
----------------------------------------

Hope this helps,

        -Trey

Author of "Accelerated C# 2005"
http://www.amazon.com/Accelerated-C-2005/dp/1590597176



> -----Original Message-----
> From: Discussion relating to the specifics of the C# and
> Managed C++ languages [mailto:[email protected]]
> On Behalf Of Chris Donovan
> Sent: Tuesday, September 05, 2006 9:54 PM
> To: [email protected]
> Subject: Re: [DOTNET-CX] C++\CLI Compiler /nostdlib option?
>
> Thanks for the suggestion, but we had found that option earlier.
> Unfortunately, the /NODEFAULTLIB linker option doesn't allow
> you to specify which mscorlib.dll you want to reference for
> metadata during the compile stage.  Also, in case I didn't
> make it clear before, we are trying to do both the compile
> and the link from the command-line, not from within Visual Studio.
>
> Chris
>
> -----Original Message-----
> From: Discussion relating to the specifics of the C# and
> Managed C++ languages [mailto:[email protected]]
> On Behalf Of Ivanoff, Alex
> Sent: Tuesday, September 05, 2006 5:08 PM
> To: [email protected]
> Subject: Re: [DOTNET-CX] C++\CLI Compiler /nostdlib option?
>
> Project Settings -> Configuration -> Linker -> Input either
> "Ignore All Default Libraries" or "Ignore Specific Library".
>
>
> -----Original Message-----
> From: Discussion relating to the specifics of the C# and
> Managed C++ languages [mailto:[email protected]]
> On Behalf Of Christopher Donovan
> Sent: Tuesday, September 05, 2006 16:42
> To: [email protected]
> Subject: [DOTNET-CX] C++\CLI Compiler /nostdlib option?
>
> Is there any command line argument in Microsoft's C++/CLI
> compiler that prevents the compiler from looking for mscorlib.dll in:
>
>         c:\windows\microsoft.net\framework\v2.0.50727\
>
> Our build environment requires that all builds be consistent
> and reproducible.  This means that there should be as little
> reliance as possible on the configuration of the particular
> machine used to build the software.  We require all
> components referenced during the build process to come from a
> single shared location, not from the user's local hard drive.
>
> C# and VB both provide the "/nostdlib" command line argument
> but I can not find anything similar in C++/CLI.
>
> Any thoughts?
>
> ===================================
> This list is hosted by DevelopMentorR  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor.  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor.  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.