기존 게임 소스 컴파일 문제 해결 노트 (Visual Studio+DirectX SDK)

2017. 1. 21. 09:54기타/Windows 개발

첫번째 문제 : "cl : 명령줄 error D8016: '/ZI'과(와) '/Gy-' 명령줄 옵션이 호환되지 않습니다."

http://r2cuerdame.blogspot.kr/2016/12/cl-error-d8016-zi-gy.html

속성 페이지 -> C/C++ -> 코드 생성 -> 함수수준 링크 사용 ->  /Gy


두번째 문제 : "포함 파일을 열 수 없습니다. 'dxerr9.h': No such file or directory"


DirectX 9 예제 프로젝트 빌드하는 방법

http://www.sysnet.pe.kr/2/0/1723

DXSDK_Jun10.exe 설치 시 "Error Code: S1023" 오류 해결하는 방법

http://www.sysnet.pe.kr/2/0/1195


아쉽게도 빌드가 안됩니다. d3dx9.h 헤더 파일이 없다고 나옵니다.

error C1083: Cannot open include file: 'd3dx9.h': No such file or directory c:\...\d3d\d3dimagesample\d3dimagesample\d3dscene\main.cpp


어쩔 수 없죠. ^^ DirectX SDK를 다운로드 받아 설치했습니다.

DirectX Software Development Kit 
; http://www.microsoft.com/en-us/download/details.aspx?id=6812


참고로, 현재 대부분의 개발자 컴퓨터에서는 DirectX SDK (June 2010)을 설치하면 S1023 오류가 발생할 것입니다. 이에 대해서는 다음의 글을 보시고 해결하면 됩니다.

DXSDK_Jun10.exe 설치 시 "Error Code: S1023" 오류 해결하는 방법
; http://www.sysnet.pe.kr/2/0/1195


물론 이렇게 해도 빌드가 안됩니다. 왜냐하면 D3DScene C++ 프로젝트의 include/lib 폴더 경로를 프로젝트 설정에서 DirectX SDK 설치 경로를 포함해 주어야 하기 때문입니다.

[include 경로]
d3d_compile_1.png 

[x86 라이브러리 경로]
d3d_compile_2.png 

여기까지 맞춰주면 D3DImageSample 솔루션 파일이 전체적으로 컴파일이 잘 됩니다

-----------------------------------------------------------------------------------------------------------------------------

[그래픽스] Rendering DX 9 :: 기본 윈도우 생성

http://vallista.tistory.com/entry/DX-9-%EA%B8%B0%EB%B3%B8-%EC%9C%88%EB%8F%84%EC%9A%B0-%EC%83%9D%EC%84%B1


http://tt91.tistory.com/44

최신버전(DirectX 11.1 / DirectX 12)의 SDK는 요즘 윈도우즈 SDK에 포함되어 나온다고 한다.

(물론 구버전의 라이브러리와 헤더도 포함되어 있다)

https://developer.microsoft.com/ko-kr/windows/downloads/windows-10-sdk


세번째 문제 : 포함 파일을 열 수 없습니다. 'dxerr9.h': No such file or directory


It seems your program was written using an older version of DirectX SDK. The 'dxerr9.h' is present at least in "Microsoft DirectX 9.0 SDK (December 2004)", but is absent at least in "Microsoft DirectX SDK (August 2009)".


* DXTRACE_ERR 매크로

http://telnet.or.kr/directx/intro/program/debugging/dxtrace_err.htm


#include <windows.h>

#include <mmsystem.h>

//#include <dxerr9.h>

//#include <dsound.h>

long __cdecl DXTRACE_ERR(char *, long) {

return long;

}

dxerr9.h 파일을 주석 처리하면, DXTRACE_ERR 매크로 정의부가 없기 때문에 DXTRACE_ERR를 사용한 모든 곳에서 에러가 난다. 그래서 임의의 함수를 하나 만들어서 대체하게 했다.


네번째 문제 : C2280: attempting to reference a deleted function (union, struct, copy constructor)


http://stackoverflow.com/questions/33921710/c2280-attempting-to-reference-a-deleted-function-union-struct-copy-construct

The relevant rule here for the union is C++14 [class.union]/1:

If any non-static data member of a union has a non-trivial default constructor , copy constructor, move constructor, copy assignment operator, move assignment operator, or destructor, the corresponding member function of the union must be user-provided or it will be implicitly deleted for the union.


C++ 14의 문법적인 문제 때문에 union을 사용할 때에도 생성자가 반드시 있어야 하는 것으로 판단된다.

union CUSTOMVERTEX_XYZ

{

struct 

{

D3DXVECTOR3 v;

};

struct 

{

FLOAT x,y,z;

};

CUSTOMVERTEX_XYZ() {}

static const DWORD FVF;

};

union CUSTOMVERTEX_XYZDIFFUSE

{

struct 

{

D3DXVECTOR3 v;

DWORD Color;

};

struct 

{

FLOAT x,y,z;

DWORD Color;

};

CUSTOMVERTEX_XYZDIFFUSE() {}

static const DWORD FVF;

};


다섯번째 문제 : lnk1104: cannot open 'LIBC.lib' LINK


http://stackoverflow.com/questions/15965716/lnk1104-cannot-open-libc-lib-link

If your application may multiple static link same library. you can go right click project->properties-> Linker -> Input -> Ignore Specific Library and add libc.lib


"특정 기본 라이브러리 무시" 항목에 다음을 추가하여 해결

strmbasd.lib;libcp.lib;dxerr9.lib;LIBC.lib


여섯번째 문제 : fatal error LNK1281: SAFESEH 이미지를 생성할 수 없습니다.


https://msdn.microsoft.com/ko-kr/library/9a89h429.aspx

/SAFESEH:NO를 지정하면 링커에서는 모든 모듈이 안전한 예외 처리 기능과 호환되더라도 안전한 예외 처리기 테이블이 있는 이미지를 생성하지 않습니다.


링커-명령줄에 "추가 옵션"으로 /SAFESEH:NO를 추가하여 해결


일곱번째 문제 : error LNK2001: "public: __thiscall std::ios_base::Init::Init(void)"


http://stackoverflow.com/questions/36081425/nuget-version-of-gtest-not-linking-in-vs2015


프로젝트 속성의 "일반" 메뉴의 "플랫폼 도구 집합"을 "Visual Studio 2015 (v140)"에서 "Visual Studio 2015 - Windows XP (v140_xp)"로 변경하여 해결


...................................................................


드디어 빌드 성공!

10년도 넘은 게임 프로그램을 빌드해서 실행하였다.

아직 몇가지 이슈를 더 해결해야 하지만, 감격적이다~