Matt.J

Hi,

I would like to know if it is possible to disable VC++ from implementing the CRL, hence preventing my code

being compiled with the inclusion of (hidden) calls to the runtime library as I have no need for it.

I don't use features that depend on the CRL, such as classes, and have resorted to 'dropping in' assembly to prevent the use of the CRL as much as possible.

Thanks in advance.

Regards,

Matt.



Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

Shakje

If you mean the CLR, use Win32 projects instead of .net projects when you create them, or go into project properties and set Common Language Runtime support to No Common Language Runtime support.




Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

Matt.J

My bad, CLR*

I am using a Win32 project, but I cannot find the "Common Language Runtime support" option.

Thanks for your help, I appreciate it.





Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

Matt.J

Could this possibly be due to my use of an earlier version of VC++ (2003)

There does not appear to be any "Common Language Runtime support" within the project's properties page.





Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

Shakje

When you create a project there should be Win32 console app and Win32 Application in the project templates, those are the ones that will not use CLR, anything such as a Windows Forms app or anything with .NET in the name will probably create a CLR based app.

I'm using 2005, but I would expect there to be a Use CLR option somewhere, have you tried in the C/C++ tab The command line option is /CLR so look for anything that specifies that.






Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

Matt.J

Hmm, well I took a look (as I have done many times before) through the C++ (and linker) options but couldn't find anything.

After reviewing the /CLR , it is off by default (implying the C runtime library is not in use) yet this is contradicted by the fact the application still does make hidden calls to the library.

Typically I will set the "Ignore All Default Libraries" option to On, this works but will result in linking errors in many conditions where the compiled code _still_ generates hidden calls. I have to manually circumvent this by dropping in assembly, which is fine, but I don't feel that I should have to.

Any more ideas





Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

crescens2k

The CLR option is in the general settings anyway. Under 2005 it is "Common Language Runtime" support on the same page as using the MFC and ATL libraries.




Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

Matt.J

Well, I'm using VC++ "2003". I guess that might explain it, but I'd think there would still be a means... even with this older version.





Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

crescens2k

Just checked my copy of 2003 and in 2003 it is "Use Managed Extentions" under the general settings.




Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

Matt.J

The /clr compiler option enables the use of Managed Extensions for C++ and creates an output file that will require the .NET Framework common language runtime at run time. There may or may not be managed data in the application.

Seems /CLR (Which "Use Managed Extensions" enables) will just cause more dependencies.





Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

crescens2k

Ah, you want to disable the CRT. Meh, I think everyone got the wrong idea from this.

First of all don't use any of the CRT functions, with out it linked then you will have no access to them.

Go to the linker options and set the entry point. This will force it to a different entry point and not the standard one. Also go and set Ignore Default Libraries to Yes.

This should get something like what you want but it would be easier for you to do a command line build.






Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

Matt.J

Yeah, precisely. Sorry if I wasn't more specific, I'm not an advocate of using other people's code and therefor never looked into the C runtime library.

What you suggested is what I usually do, custom entry point and disabling the loading of the default libraries. Yet, CRT calls are still made on various occasions (such as when any FPU use is required.)





Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

crescens2k

Well, all you can try to do is look at the options of the compiler. The problem here is that the VC compiler assumes a hosted environment so it assumes that there is a runtime library to work with.

Things you can try though are the /Zl option, this disables the compiler from putting the default library name into the object file. Make sure you don't use any of the /RTC options. Try also looking at /Op- since /Op is to improve floating point consistancy, maybe this injects the floating point code.

Edit:

After looking through a few things there are two things you need to do to your code in order to use floating point correctly. First define somewhere in your source.

extern"C" _fltused=1;

Otherwise you will just get an unresolved external.

The second thing you should do is use the /QIfist compiler option. This will stop it from using ftol when converting from floating point to integer.






Re: Visual C++ General Disabling the CRL (Visual C++ 2003)

talewisx

The compiler generates calls to a number of support library functions. You can't prevent this other than by not using the C/C++ compiler feature. In general, in VC++ 2003, these are related to floating point and 64-bit integer math. In VS 2005, there are a couple of others (memcpy/memset being the examples I recall off hand). You can disable the latter by turning off optimization.