473,888 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

/clr:pure and unmanaged lib

I have a small C++/CLI application which calls an unmanaged lib.

It seems like I can't use /clr:pure and link with the unmanaged lib (LNK1313
error).

The problem I have is that compiling with /clr adds a dependency on several
msvc*.dll:s which adds some unwanted complexity to the installation.

Is it possible to avoid the msvc*.dll dependency without explicit p/invoke?
Oct 4 '07 #1
13 3659

"wpcmame" <wp*****@discus sions.microsoft .comwrote in message
news:05******** *************** ***********@mic rosoft.com...
>I have a small C++/CLI application which calls an unmanaged lib.

It seems like I can't use /clr:pure and link with the unmanaged lib
(LNK1313
error).
Of course. /clr:pure means your assembly contains only MSIL, but you're
putting in machine code from a native library.
>
The problem I have is that compiling with /clr adds a dependency on
several
msvc*.dll:s which adds some unwanted complexity to the installation.

Is it possible to avoid the msvc*.dll dependency without explicit
p/invoke?
No. But this shouldn't surprise anyone, if you compile for .NET you will
need the .NET runtime installed. The .NET runtime is built using C++, so it
deploys msvc*.dll

Now the whole side-by-side versioning problem is another story. I think it
might be fixed if MS deployed the C++ updates in a .NET 2.0 runtime patch,
but for some reason they insist on distributing old versions of the library
(even though the new ones are compatible and include bug fixes).
Oct 4 '07 #2
Hi Ben!
>Is it possible to avoid the msvc*.dll dependency without explicit
p/invoke?

No. But this shouldn't surprise anyone, if you compile for .NET you will
need the .NET runtime installed. The .NET runtime is built using C++, so it
deploys msvc*.dll
????

The .NET runtime does not depend on the msvc*.dlls!
Only if you compiler in C++/CLI with "/clr", then your application will
depend on the CRT!

The .NET runtime does not deply msvc*.dlls....

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Oct 4 '07 #3
"Jochen Kalmbach [MVP]" <no************ ********@holzma .dewrote in message
news:eY******** *****@TK2MSFTNG P02.phx.gbl...
Hi Ben!
>>Is it possible to avoid the msvc*.dll dependency without explicit
p/invoke?

No. But this shouldn't surprise anyone, if you compile for .NET you will
need the .NET runtime installed. The .NET runtime is built using C++, so
it deploys msvc*.dll

????

The .NET runtime does not depend on the msvc*.dlls!
Only if you compiler in C++/CLI with "/clr", then your application will
depend on the CRT!

The .NET runtime does not deply msvc*.dlls....
Jochen,
mscorjit.dll, mscorwks.dll etc are linked against the MSVCRXX.dll, where XX
stands for the version of the VC runtime, a simple dumpbin /imports may show
you that.

Willy.

Oct 4 '07 #4
Hi Willy!
>>No. But this shouldn't surprise anyone, if you compile for .NET you
will need the .NET runtime installed. The .NET runtime is built
using C++, so it deploys msvc*.dll

????

The .NET runtime does not depend on the msvc*.dlls!
Only if you compiler in C++/CLI with "/clr", then your application
will depend on the CRT!

The .NET runtime does not deply msvc*.dlls....

Jochen,
mscorjit.dll, mscorwks.dll etc are linked against the MSVCRXX.dll,
where XX stands for the version of the VC runtime, a simple dumpbin
/imports may show you that.
Upps... interesting feature....

But this does not mean, that you do not need to redistribute the
vcredist_x86.ex e if you compile with "/clr".

I assume that the mscor*.dll are linked agains the RTM (or previous)
version of the CRT. So if you build your app with VS2005SP1, you need to
deploy the SP1 DLLS...

I general you can say:
If you compile with /clr:pure, you only need the .NET-Redistributable .
Otherwise you also need the vcredist_x86.ex e
Also if you use MFC/ATL/OpenMP, you need to use vcredist_x86.ex e
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Oct 4 '07 #5
Hi Willy!
If you are building against a newer version, somehow you'll have to add
the VC runtime too (or link statically).
Starting with VS2005 it is not supported to use /clr and link statically
against the CRT ;)
only "safe" assemblies do not depend on VCRT, all others depend on the
VCRT and are not verifiable.
Upps... thanks for clarification.. .
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Oct 4 '07 #6
"Jochen Kalmbach [MVP]" <no************ ********@holzma .dewrote in message
news:O6******** *****@TK2MSFTNG P05.phx.gbl...
Hi Willy!
>If you are building against a newer version, somehow you'll have to add
the VC runtime too (or link statically).

Starting with VS2005 it is not supported to use /clr and link statically
against the CRT ;)
True :-(
>only "safe" assemblies do not depend on VCRT, all others depend on the
VCRT and are not verifiable.

Upps... thanks for clarification.. .
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Oct 4 '07 #7
"Ben Voigt [C++ MVP]" <rb*@nospam.nos pamwrote in message
news:Od******** ******@TK2MSFTN GP04.phx.gbl...
>>But this does not mean, that you do not need to redistribute the
vcredist_x86. exe if you compile with "/clr".

If you are building against a newer version, somehow you'll have to add
the VC runtime too (or link statically).
>>I assume that the mscor*.dll are linked agains the RTM (or previous)
version of the CRT. So if you build your app with VS2005SP1, you need to
deploy the SP1 DLLS...

Yep.

Unless you use redirection. The public interface isn't changed, so you
can use any version of the VC8 runtime -- as long as you manifest is set
that way.
Agreed.
But because the VC8 runtime is backward compatible, there is no excuse for
Microsoft not to include the newer dlls in the next .NET 2.0 patch. If
they are compiling patches to .NET 2.0 using RTM.... that's bad news,
there were a lot of compiler and library bugs fixed in SP1.
The actual patches are compiled with the vs2005 SP1 bug fixes (and more)
included. With Orcas comes a new version of the CLR including more fixes and
a new version of the VC run time.
>>
>>I general you can say:
If you compile with /clr:pure, you only need the .NET-Redistributable .
Otherwise you also need the vcredist_x86.ex e
Also if you use MFC/ATL/OpenMP, you need to use vcredist_x86.ex e

Nope, a pure is not MSIL only assembly, "pure" assemblies still have the
VCRT linked in, take a look at the assembly manifest generated by the
compiler, this manifest contains the assembly's depencies, something
like.

Pure is MSIL only, but the CRT includes an MSIL version of some functions,
so the dependency still exists.
It was my understanding that the C compiler team had reserved the right to
"inject" MSIL as well as native code whenever they see fit.
I remember this was done to allow them to inject native code when MSIL was't
really an option, I'll try to find the source of this info and post back
when I've found it. In the mean time consider my understanding to be wrong.

Willy.

Oct 4 '07 #8
>But because the VC8 runtime is backward compatible, there is no excuse
>for Microsoft not to include the newer dlls in the next .NET 2.0 patch.
If they are compiling patches to .NET 2.0 using RTM.... that's bad news,
there were a lot of compiler and library bugs fixed in SP1.

The actual patches are compiled with the vs2005 SP1 bug fixes (and more)
included. With Orcas comes a new version of the CLR including more fixes
and a new version of the VC run time.
But if you go to Windows Update (repeatedly) and install .NET 2.0 and all
patches, you get an old, buggy, runtime library installed and not the new
one with the bug fixes. I think this is poor behavior.
Oct 4 '07 #9
"Ben Voigt [C++ MVP]" <rb*@nospam.nos pamwrote in message
news:OR******** ******@TK2MSFTN GP06.phx.gbl...
>>But because the VC8 runtime is backward compatible, there is no excuse
for Microsoft not to include the newer dlls in the next .NET 2.0 patch.
If they are compiling patches to .NET 2.0 using RTM.... that's bad news,
there were a lot of compiler and library bugs fixed in SP1.

The actual patches are compiled with the vs2005 SP1 bug fixes (and more)
included. With Orcas comes a new version of the CLR including more fixes
and a new version of the VC run time.

But if you go to Windows Update (repeatedly) and install .NET 2.0 and all
patches, you get an old, buggy, runtime library installed and not the new
one with the bug fixes. I think this is poor behavior.

Oh, but there are more patches (hotfixes) than those supplied via WUS, there
are the fixes released through "PSS" and fixes available via "Premium
Contract" Services. That' said, the latest fix I got for an issue on
mscorjit.dll (X64) was build against the SP1 msvcrt80.dll (not that it had
anything to do with the CRT itself).
The RTM downloads of the V2 framework, are all build against the pre-VS2005
SP1 CRT libraries, SP1 for VC2005 contains fixes for C++ tools and
libraries like MFC, ATL and a some OLE, but (AFAIK) no msvcrt80.dll fixes.
The CLR doesn't depend on MFC nor on ATL, so IMO the version of the msvcrt
is a non-issue, unless you have found a bug in the CLR code that relates to
the C run-time.

Willy.
Oct 5 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2629
by: Gustavo L. Fabro | last post by:
Greetings! Some classes that once compiled without problems on VS 2003 have now problems on VS 2005 Beta 1. I'm talking about a __nogc class that is exported with __declspec(dllexport). The compiler message is this: VCSelectLibraryForm.cpp ...\Forms\QiForm.h(48) : error C3395: 'TQiForm::GetDotNetMouseButton' :
2
4798
by: Peter Oliphant | last post by:
I've gotten my application to compile under '/clr'. I then tried '/clr pure' and it compiled immedately with no changes. What should I consider when deciding which of these two option to compile under? Are there advantages and disadvantages to one over the other? I also tried compiling it using the '/clr safe' option and got 6420 errors (no, that's not the error number, that's the number of errors). So don't think I'll go that route just...
5
1465
by: Bart | last post by:
Hi, What is the benefit of using the Pure option over the Mixed one. Is there a better performance? We have a lot of stuff in c++ with mfc support en we want to use in our .net apps. With mixed setting we can compile including the mfc part of our code. We can get rid of the mfc code but it will cost us some effort so we can use the pure setting in that case.
2
1767
by: Vedo | last post by:
The MSDN documentation says that the GetLastError function can give undefined behavior when compiling with /clr:pure switch. Does this statement apply to both C++ interop and P/Invoke? If yes, does it mean that we have to use Marshal::GetLastWin32Error to check the last error code?
1
1185
by: =?iso-8859-1?q?Horacio_Nu=F1ez_Hern=E1ndez?= | last post by:
Hi, I have been writing a wrapper with /clr:pure set, while I using the debug mode it was fine, when turned the mode to release it begins show me the same errors that when we try to use unmanaged functions whithout specify the input libs to the linker, thanks in advance, regards
10
7013
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lparam) {
0
9959
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9800
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10772
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10880
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10434
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9593
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7988
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7144
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3246
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.