VC2019 로 python-2.7.18 컴파일하기

VC2019 를 사용하여 python-2.7.18을 컴파일하려면 아래와 같은 절차로 일부 파일을 수정해야 합니다.

  1. posixmodule.obj : error LNK2019: __imp____pioinfo__PyVerify_fd 함수에서 참조되는 확인할 수 없는 외부 기호
    Python-2.7.18\Modules\posixmodule.c 의 _PyVerify_fd() 를 아래와 같이 수정
/* This function emulates what the windows CRT does to validate file handles */
int
_PyVerify_fd(int fd)
{
#if 1
    return _get_osfhandle(fd) >= 0;
#else
    const int i1 = fd >> IOINFO_L2E;
    const int i2 = fd & ((1 << IOINFO_L2E) - 1);

    static int sizeof_ioinfo = 0;

    /* Determine the actual size of the ioinfo structure,
     * as used by the CRT loaded in memory
     */
    if (sizeof_ioinfo == 0 && __pioinfo[0] != NULL) {
        sizeof_ioinfo = _msize(__pioinfo[0]) / IOINFO_ARRAY_ELTS;
    }
    if (sizeof_ioinfo == 0) {
        /* This should not happen... */
        goto fail;
    }

    /* See that it isn't a special CLEAR fileno */
    if (fd != _NO_CONSOLE_FILENO) {
        /* Microsoft CRT would check that 0<=fd<_nhandle but we can't do that.  Instead
         * we check pointer validity and other info
         */
        if (0 <= i1 && i1 < IOINFO_ARRAYS && __pioinfo[i1] != NULL) {
            /* finally, check that the file is open */
            my_ioinfo* info = (my_ioinfo*)(__pioinfo[i1] + i2 * sizeof_ioinfo);
            if (info->osfile & FOPEN) {
                return 1;
            }
        }
    }

  fail:
    errno = EBADF;
    return 0;
#endif
}
  • python-2.7.18\externals\tk-8.5.19.0\xlib\X11\X.h
    windows.h를 추가
#define X_PROTOCOL	11		/* current protocol version */
#define X_PROTOCOL_REVISION 0		/* current minor version */
/* patched, include "windows.h" first to avoid conflict macro */
#ifdef _WIN32
#   define WIN32_LEAN_AND_MEAN
#   include <windows.h>
#   undef WIN32_LEAN_AND_MEAN
#endif
  • Python-2.7.18\PCbuild\tcltk.props
    VC9 를 VC13으로 수정
    <BuildDirTop Condition="$(TclMachine) != 'IX86'">$(BuildDirTop)_$(TclMachine)</BuildDirTop>
    <!-- This completely breaks building Tix for any toolset but v90 and should be fixed -->
    <BuildDirTop>$(BuildDirTop)_VC13</BuildDirTop>
  </PropertyGroup>
</Project>

이제 컴파일을 하면 정상적으로 완료됩니다.
만약 컴파일이 안되면 아래 절차를 따라 하시면 됩니다.

  1. PCBuild 로 이동
  2. get_externals.bat -c 실행하여 externals 폴더에 외부 파일을 다운로드 함
  3. pcbuild.sln 을 열고 솔루션 정리 후 솔루션 빌드
  4. 빌드 실행 중에 externals folder에 tcltk 폴더가 생성되면 정상적으로 컴파일이 수행됨

This entry was posted in Window Program and tagged , , . Bookmark the permalink.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다