반응형

http://evax.springnote.com/pages/4607951.xhtml

 

현재 개발환경에서는 최신 공용 라이브러리 링크에 문제점이 발생하게 되는데 Visual Studio sp1이 설치된 개발머신에서 Visual Studio2008로 컴파일을 할 경우, 메니페스트는 기존 Visual Studio2008용 라이브러리들의 정보가 기술되게 됩니다. 따라서, 개발은 sp1에 포함된 라이브러리에서 되었지만 실행은 구버전의 라이브러리로 되는 현상이 발생하게 됩니다. 이는 tr1과 같은 라이브러리의 새로운 기능이나 MFC의 새로운 기능을 사용했을 때 문제가 될 소지가 더 많게 됩니다.

 

따라서 최신 버전의 라이브러리 버전을 기술해 주는 작업이 필요한데, 코드상으로 이 부분을 선언 해 줄 수 있습니다.

#define _BIND_TO_CURRENT_CRT_VERSION 1
#define _BIND_TO_CURRENT_ATL_VERSION 1
#define _BIND_TO_CURRENT_MFC_VERSION 1#define _BIND_TO_CURRENT_OPENMP_VERSION 1

 

이름을 보면 알 수 있듯, 이 상수는 현재 사용하고 있는 라이브러리의 버전을 메니페스트에 바인딩 해주는 작업을 합니다. 이 네가지의 상수를 하나로 묶어서 다음과 같이 하나의 상수만 선언해 주어도 4개를 선언한것과 동일한 효과를 거둘 수 있습니다.

 

#define _BIND_TO_CURRENT_VCLIBS_VERSION 1

 

이 상수는 프리프로세스에 선언해 주는 것이 좋습니다. stdafx.h에 선언하게 되면 중복선언 되는 케이스가 생길 수도 있고 프로젝트에 따라 프리컴파일드 헤더를 사용하지 않을 경우 선언하는 곳이 모호해질 수 있는 문제가 있습니다.(2009-01-23 revolution 팀장님 감사합니다. ^^) 컴파일이 처음 되는 stdafx.h의 가장 상단 같은 곳에 선언해 주는 것이 좋습니다. Visual Studio 2008 sp1을 설치한 다음 현재 라이브러리 바인드 상수를 선언한 후 애플리케이션을 컴파일 하면 다음과 같이 sp1의 라이브러리 버전으로 바인드 되어 있음을 확인할 수 있습니다. 공용 CRT 라이브러리와 공용 MFC 라이브러리 버전이 9.0.21022.8에서 9.0.30729.1로 변경된 부분에 주목해 주세요.

 

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">

<security>

<requestedPrivileges>

<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>

</requestedPrivileges>

</security>

</trustInfo>

<dependency>

<dependentAssembly>

<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.1" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>

</dependentAssembly>

</dependency>

<dependency>

<dependentAssembly>

<assemblyIdentity type="win32" name="Microsoft.VC90.MFC" version="9.0.30729.1" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>

</dependentAssembly>

</dependency>

<dependency>

<dependentAssembly>

<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>

</dependentAssembly>

</dependency>

</assembly>

 


 

 


 


 


Visual C++ 동적으로 MFC 를 사용할 경우 필요한 DLL 파일들  Information 

2008/08/14 16:26

복사http://blog.naver.com/ysoftman/20053674809

MFC 를 동적으로 사용할 경우 필요한 dll 로, exe 와 같은 폴더나 시스템 폴더에 존재해야 한다.

 

// DEBUG 경우

// Visual C++ 6.0 경우

mfc42d.dll  mfco42d.dll msvcirtd.dll msvcrtd.dll

// Visual C++ 9.0 (2008) 경우

mfc90d.dll mfcm90d.dll msvcpm90d.dll msvcp90d.dll msvcr90d.dll

 

// RELEASE 경우

// Visual C++ 6.0 경우

mfc42.dll  mfco42.dll msvcirt.dll msvcrt.dll

// Visual C++ 9.0 (2008) 경우

mfc90.dll mfcm90.dll msvcpm90.dll msvcp90.dll msvcr90.dll



1 개요

VisualCpp 8.0부터 뭔가 배포가 귀찮아졌다.

A required .DLL file, "MSVCR80.dll" was not found.
app.exe has failed to start because the application configuration is incorrect.
응용프로그램 구성이 올바르지 않기 때문에 이 응용 프로그램을 시작하지 못했습니다. 이 문제를 해결하려면 응용 프로그램을 다시 설치하십시오.


2 Side-by-side Assembly

DLL 충돌 문제 때문에 마이크로소프트가 Side-by-side Assembly인지 뭔지를 만들었다. 같은 컴퓨터 안에서 여러 버전의 DLL을 동시에 실행할 수 있도록 해주는 기능인 모양이다. 즉 각각의 애플리케이션에게 독립적인 DLL 환경을 보장해준다는 말이다. 이 파일들은 \Windows\WinSxS 디렉토리에 존재한다. Side-by-side Assembly가 무엇인지는 .NET 어셈블리 쪽을 참고하기 바란다.

어쨌든 이것 때문에 기존 방식(배포할 애플리케이션과 같은 디렉토리에 VisualCpp 런타임 DLL을 같이 넣어두기)이 통하지 않게 되었다. 애플리케이션을 정상적으로 돌아가게 하기 위해서는 이 Side-by-side DLL들을 배포하고, 뭔가 레지스트리를 잔뜩 건드려야한다.


3 해결 방안

3.1 윈도우즈 인스톨러를 이용해 셋업 프로젝트를 만든다

아. 짱나.

3.2 VC 8.0 안에 있는 셋업 파일을 같이 배포한다

위 파일을 먼저 설치한 후, 원래 애플리케이션을 돌리면 된다. 그런데 이상하게 인스톨 화면도 딱히 없고, 프로세스 창에 msiexec.exe가 반응이 없는 채로 상당 시간 떠 있는 것을 볼 수 있다. 뭐 어쨌든 설치는 되더라. 비교적 간단한 방법이기는 하지만 이넘을 실행시키기 위해 필요한 것들이 많다는 게 문제다.

from [WWW]http://www.codeproject.com/useritems/vcredists_x86.asp

OSInstallableRequired Service PackOther Software
Windows 3.x/NT/95NoN/AN/A
Windows 98/MEYesInternet Explorer 5.0 required (included in Win98SE/ME)Windows Installer 2.0 required
Windows 2000YesService Pack 3 required (includes Windows Installer 2.0)Windows Installer 3.0 required
Windows XPYesService Pack 2 RecommendedWindows Installer 3.0 required (included in Service Pack 2)
Windows Server 2003YesService Pack 1 RecommendedWindows Installer 3.0 required (Windows Installer 3.1 included in Service pack 1)
Windows VistaYesNoneNone


3.3 Private Assembly를 설치한다

실행 파일 자체와 실행 파일에서 액세스하는 DLL들에 대한 manifest 파일들을 private assembly로서 같이 배포하면, 에러를 피할 수 있다. 실행 파일의 manifest 파일은 오브젝트 파일 생기는 디렉토리 잘 뒤져보면 있을 것이다. 대충 아래와 같은 내용이다.

XXX.exe.manifest
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> 
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> 
  <dependency> 
    <dependentAssembly> 
      <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> 
    </dependentAssembly> 
  </dependency> 
  <dependency> 
    <dependentAssembly> 
      <assemblyIdentity type='win32' name='Microsoft.VC80.MFC' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> 
    </dependentAssembly> 
  </dependency> 
</assembly> 

그 다음 각각의 어셈블리, 즉 DLL에 대한 manifest 파일도 같이 배포해야 한다. (이 파일들은 기본적으로 ...\Microsoft Visual Studio 8\VC\redist 디렉토리 아래에 각 플랫폼 별로 존재한다.)

Microsoft.VC80.CRT.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>  
<!-- Copyright &copy; 1981-2001 Microsoft Corporation-->  
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">  
<noInheritable/>  
<assemblyIdentity  
    type="win32"  
    name="Microsoft.VC80.CRT"  
    version="8.0.50608.0"  
    processorArchitecture="x86"  
    publicKeyToken="1fc8b3b9a1e18e3b" />  
<file name="msvcr80.dll"/>  
<file name="msvcp80.dll"/>  
<file name="msvcm80.dll"/>  
</assembly>  
Microsoft.VC80.MFC.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>  
<!-- Copyright &copy; 1981-2001 Microsoft Corporation-->  
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">  
<noInheritable/>  
<assemblyIdentity  
    type="win32"  
    name="Microsoft.VC80.MFC"  
    version="8.0.50608.0"  
    processorArchitecture="x86"  
    publicKeyToken="1fc8b3b9a1e18e3b" />  
<file name="mfc80.dll"/>  
<file name="mfc80u.dll"/>  
<file name="mfcm80.dll"/>  
<file name="mfcm80u.dll"/>  
</assembly>  
이 manifest 파일과 DLL 파일들을 애플리케이션 실행 파일이 존재하는 디렉토리에 같이 넣어두면, 별도의 셋업 없이도 실행이 된다. 문제는 이렇게 했을 때, 저 DLL들의 새 버전이 나와도 XXX.exe는 이 혜택을 받을 수 없다는 점이다.

3.4 .NET framework 2.0을 설치한다

다운 열라 받아야함...

3.5 CRT 소스를 이용해 커스텀 CRT를 빌드한다

빌드한 파일을 마이크로소프트에서 배포하는 이름과 똑같은 이름으로 배포하면 법에 저촉되는 모양이다. 사실 빌드하기도 귀찮다.

3.6 정적 링크를 이용한다

C/C++ > Code Generation 항목에서 DLL 버전 말고 정적 CRT를 사용하도록 한다. 제일 간단한 방법이기는 하지만, 온라인 게임 클라이언트 같은 경우에는 매번 업데이트 때마다 커다란 크기의 실행 파일을 다운로드받아야하는 단점이...
출처
  
http://serious-code.net/moin.cgi/RedistributingVisualCppRunTimeLibrary

반응형

+ Recent posts