PDF 다운로드PDF 다운로드

DLL 파일은 C++로 작성하고 제어하는 동적 링크 라이브러리 파일이다. DLL은 코드를 간편하게 공유하고 저장할 수 있다. 이 글을 통해 PC용 비주얼 스튜디오나 맥용 비주얼 스튜디오]로 DLL 파일을 만드는 방법을 알아보자. 설치할 때 "C++를 사용한 데스크톱 개발"에 체크해야 한다. 이미 비주얼 스튜디오가 있지만 체크를 하지 않은 경우 설치 프로그램을 다시 실행해 확실히 설치한다.

  1. How.com.vn 한국어: Step 1 비주얼 스튜디오를 연다.
    시작 메뉴나 응용 프로그램 폴더에서 있다. DLL은 정보 라이브러리이기 때문에 프로젝트의 일부일 뿐이며 액세스하려면 관련 응용 프로그램이 필요하다.
  2. How.com.vn 한국어: Step 2 파일
    을 클릭한다. 프로젝트 공간(PC)위 또는 화면 상단(맥)에 있다.
  3. How.com.vn 한국어: Step 3 새로 만들기
    프로젝트를 클릭한다. "새 프로젝트 만들기" 대화 상자가 나타난다.
  4. Step 4 "언어", "플랫폼", "프로젝트 형식"을 설정한다.
    이에 따라 프로젝트 템플릿이 정해진다.
    • "언어"를 클릭해 드롭다운 메뉴를 펼치고 "C++"를 클릭한다.
  5. Step 5  "플랫폼"을 클릭해 드롭다운 메뉴를 펼치고 "Windows"를 클릭한다.
  6. Step 6  "프로젝트 형식"을 클릭해 드롭다운 메뉴를 펼치고 "라이브러리"를 클릭한다.
  7. How.com.vn 한국어: Step 7 동적 연결 라이브러리(DLL)
    를 클릭한다. 파란색으로 강조된다. "다음"을 클릭해 계속한다.
  8. How.com.vn 한국어: Step 8 프로젝트 이름 상자에 이름을 입력한다.
    예를 들어 이름 상자에 "MathLibrary"를 입력한다.
  9. How.com.vn 한국어: Step 9 만들기
    를 클릭한다. DLL 프로젝트가 생성된다.
  10. How.com.vn 한국어: Step 10 DLL에 헤더 파일을 추가한다.
    메뉴 모음의 "프로젝트"에서 "새 항목 추가"를 클릭한다.
    • 대화 상자의 왼쪽 메뉴에서 "Visual C++"를 선택한다.
    • 대화 상자 가운데에서 "헤더 파일(.h)"을 선택한다.
    • 메뉴 선택 아래 이름란에 "MathLibrary.h"를 입력한다.
    • "추가"를 클릭해 빈 헤더 파일을 만든다.
  11. How.com.vn 한국어: Step 11 빈 헤더 파일에 코드를 다음과 같이 입력한다.
      // MathLibrary.h - Contains declarations of math functions#pragma once#ifdef MATHLIBRARY_EXPORTS#define MATHLIBRARY_API __declspec(dllexport)#else#define MATHLIBRARY_API __declspec(dllimport)#endif// The Fibonacci recurrence relation describes a sequence F// where F(n) is { n = 0, a//               { n = 1, b//               { n > 1, F(n-2) + F(n-1)// for some initial integral values a and b.// If the sequence is initialized F(0) = 1, F(1) = 1,// then this relation produces the well-known Fibonacci// sequence: 1, 1, 2, 3, 5, 8, 13, 21, 34, ...// Initialize a Fibonacci relation sequence// such that F(0) = a, F(1) = b.// This function must be called before any other function.extern "C" MATHLIBRARY_API void fibonacci_init(    const unsigned long long a, const unsigned long long b);// Produce the next value in the sequence.// Returns true on success and updates current value and index;// false on overflow, leaves current value and index unchanged.extern "C" MATHLIBRARY_API bool fibonacci_next();// Get the current value in the sequence.extern "C" MATHLIBRARY_API unsigned long long fibonacci_current();// Get the position of the current value in the sequence.extern "C" MATHLIBRARY_API unsigned fibonacci_index();
    • 이것은 마이크로소프트 도움말 사이트에서 제공하는 샘플 코드이다.
  12. How.com.vn 한국어: Step 12 DLL에 CPP 파일을 추가한다.
    메뉴 모음의 "프로젝트"에서 "새 항목 추가"를 클릭한다.
    • 대화 상자의 왼쪽 메뉴에서 "Visual C++"를 선택한다.
    • 대화 상자 가운데에서 "C++파일(.cpp)"을 선택한다.
    • 메뉴 선택 아래 이름란에 "MathLibrary.cpp"을 입력한다.
    • "추가"를 클릭해 빈 파일을 만든다.
  13. How.com.vn 한국어: Step 13 빈 파일에 코드를 다음과 같이 입력한다.
      // MathLibrary.cpp : Defines the exported functions for the DLL.#include "stdafx.h" // use pch.h in Visual Studio 2019#include <utility>#include <limits.h>#include "MathLibrary.h"// DLL internal state variables:static unsigned long long previous_;  // Previous value, if anystatic unsigned long long current_;   // Current sequence valuestatic unsigned index_;               // Current seq. position// Initialize a Fibonacci relation sequence// such that F(0) = a, F(1) = b.// This function must be called before any other function.void fibonacci_init(    const unsigned long long a,    const unsigned long long b){    index_ = 0;    current_ = a;    previous_ = b; // see special case when initialized}// Produce the next value in the sequence.// Returns true on success, false on overflow.bool fibonacci_next(){    // check to see if we'd overflow result or position    if ((ULLONG_MAX - previous_ < current_) ||        (UINT_MAX == index_))    {        return false;    }    // Special case when index == 0, just return b value    if (index_ > 0)    {        // otherwise, calculate next sequence value        previous_ += current_;    }    std::swap(current_, previous_);    ++index_;    return true;}// Get the current value in the sequence.unsigned long long fibonacci_current(){    return current_;}// Get the current index position in the sequence.unsigned fibonacci_index(){    return index_;}
    • 이것은 마이크로소프트 도움말 사이트에서 제공하는 샘플 코드이다.
  14. How.com.vn 한국어: Step 14  메뉴 모음에서 빌드를 클릭한다.
    프로젝트 공간(PC)위 또는 화면 상단(맥)에 있다.
  15. How.com.vn 한국어: Step 15 솔루션 빌드
    를 클릭한다. 클릭하면 다음과 같은 텍스트가 나타난다.
      1>------ Build started: Project: MathLibrary, Configuration: Debug Win32 ------1>MathLibrary.cpp1>dllmain.cpp1>Generating Code...1>   Creating library C:\Users\username\Source\Repos\MathLibrary\Debug\MathLibrary.lib and object C:\Users\username\Source\Repos\MathLibrary\Debug\MathLibrary.exp1>MathLibrary.vcxproj -> C:\Users\username\Source\Repos\MathLibrary\Debug\MathLibrary.dll1>MathLibrary.vcxproj -> C:\Users\username\Source\Repos\MathLibrary\Debug\MathLibrary.pdb (Partial PDB)========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    • DLL 만들기에 성공했다면 여기에서 볼 수 있다. 오류가 발생한 경우 수정할 수 있도록 여기에 나타난다.[1]
    광고


이 위키하우에 대하여

How.com.vn 한국어: 위키하우 직원
공동 작성자 :
위키하우 소속 작가
이 글은 위키하우 편집팀과 전문 조사원이 공동 작성하였으며 정확성 검토가 완료 되었습니다.

위키하우 콘텐츠 관리팀은 작성된 모든 글이 위키하우 글 작성 규정을 준수하는지 꾸준히 검토합니다. 조회수 10,755회
글 카테고리: 컴퓨터
이 문서는 10,755 번 조회 되었습니다.

이 글이 도움이 되었나요?

⚠️ Disclaimer:

Content from Wiki How 한국어 language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

Notices:
  • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
  • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
  • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
  • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

광고