프로그래밍/C++

LNK2019, LNK1120 해결법

우대비 2022. 12. 15. 18:58
반응형

 

#include <windows.h>
#include <wrl.h>
#include <d3dcommon.h>
#include <exception>
#include <d3d12sdklayers.h>
#include <dxgi1_4.h>

using namespace Microsoft::WRL;

inline void ThrowIfFailed(HRESULT hr)
{
	// DirectX API 오류를 탐지하기 위해 이 줄에 중단점 설정
	if (FAILED(hr))
		throw std::exception();
}

int main() 
{

	#if defined(DEBUG) || defined(_DEBUG)
	{ // 디버그층 활성화
		ComPtr<ID3D12Debug> debugController;
		ThrowIfFailed(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)));
		debugController->EnableDebugLayer();
	}
	#endif


	ComPtr<IDXGIFactory4> mdxgiFactory;
	ThrowIfFailed(CreateDXGIFactory1(IID_PPV_ARGS(&mdxgiFactory)));


	// 하드웨어 어댑터를 나타내는 장치를 생성
	ComPtr<ID3D12Device> md3dDevice;// = ComPtr<ID3D12Device>();
	HRESULT hardwareResult = D3D12CreateDevice(
		nullptr,
		D3D_FEATURE_LEVEL_11_0,
		IID_PPV_ARGS(&md3dDevice));


	// 실패했다면 WARP 어댑터를 나타내는 장치를 생성
	if (FAILED(hardwareResult))
	{
		ComPtr<IDXGIAdapter> pWarpAdapter;// = ComPtr<IDXGIAdapter>();
		ThrowIfFailed(mdxgiFactory->EnumWarpAdapter(IID_PPV_ARGS(&pWarpAdapter)));

		ThrowIfFailed(D3D12CreateDevice(
			pWarpAdapter.Get(),
			D3D_FEATURE_LEVEL_11_0,
			IID_PPV_ARGS(&md3dDevice)
		));
	}
}

위와 같이 여러 header를 포함시켜서 프로그래밍을 하고있는데

아래와 같은 에러가 뜬다!?

 

 

 

#pragma comment(lib, "d3d12")
#pragma comment(lib, "dxgi")

그렇다면 library를 추가해주면 됨~

 

반응형
LIST

'프로그래밍 > C++' 카테고리의 다른 글

C++ 파일 탐색  (0) 2023.10.17
스마트 포인터  (0) 2022.11.10
C++ Lambda  (0) 2022.11.10
전달 참조(보편 참조)와 forward  (0) 2022.11.09
오른값(rvalue)과 이동 대입 연산자  (0) 2022.11.09