64bits(x64) Windows에 32bits(x86) 프로그램 배포하기

  • 동기 :
    1. XP 32bits 개발 환경에서 컴파일한 프로그램을 64bits Vista에 설치 하고,
    2. 필요한 라이브러리인 64bits용 C++ Runtime Library를 설치하였으나,
    3. C++ Runtime Library Load 실패로 프로그램 수행시 에러 발생
  • 환경 :
    • .NET 3.5 기반 WPF 응용 프로그램
    • 통신 Module로 WIN 32 기반으로 개발된 C++/CLI DLL 라이브러리 사용
  • 원인 :
    • .NET Application 및 .NET Library들이 Any CPU로 기본 설정되어 컴파일됨
    • 통신 Module인 Win 32 C++/CLI DLL 라이브러리는 Build의 “대상 컴퓨터(/MACHINE)“이 x86으로 설정되어 컴파일됨
    • VISTA 64bits에서 수행시 .NET Application 및 다른 Control 들은 64bits 모드로 수행됨
    • 응용프로그램에서 통신 모듈의 객체 또는 함수에 접근시 해당 DLL load에 실패함
  • 해결책 :
    • target machine을 x64로 바꾸어 C++/CLI DLL 라이브러리를 컴파일 할 수도 있으나,
    • 소스가 없는 다른 3rd part DLL을 해당 라이브러리에서 사용한다면 여전히 다른 문제가 발생할 수 있음.
    • 또한 64bits 확장으로 인한 코드 상의 문제가 발생할 수도 있음
    • 따라서 비록 성능 저하가 있더라도 32bits 호환 모드로 응용 프로그램이 동작하도록 강제하는 것이 가장 안전한 방법임
  • .NET 응용 프로그램이 64bits Windows OS에서도 32bits 호환모드로 동작하도록 컴파일 하기
    • .Net 용 응용 프로그램 및 라이브러리의 프로젝트 [속성] → [빌드] → [플래폼 대상] 을 x86으로 설정
  • 주의 :
  • 참조 :

소수 구하는 프로그램

소수 구하기

/*
 ============================================================================
 Name        : calc_primenum.c
 Author      :
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */
 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main()
{
        int *prime_list = NULL;
        int size = 0;
 
        int n = 0;
        int i, j;
 
        int found = 0;
        int root = 0;
 
        scanf("%d", &n);
 
        prime_list = malloc(sizeof(int) * n / 2);
        prime_list[0] = 2;
        prime_list[1] = 3;
        prime_list[2] = 5;
        size = 3;
 
        if (n > 0)
        {
                printf("%d\n", 2);
        }
        if (n > 1)
        {
                printf("%d\n", 3);
        }
        if (n > 2)
        {
                printf("%d\n", 5);
        }
        for ( i = 7 ; i < n ; i += 2 )
        {
                if (i % 10 == 5)
                {
                        continue;
                }
                root = sqrt(i);
                for ( j = 0 ; j < size ; j++ )
                {
                        if ( prime_list[j] > root )
                        {
                                found = 0;
                                break;
                        }
                        else if ( i % prime_list[j] == 0 )
                        {
                                found = 1;
                                break;
                        }
                }
                if ( !found )
                {
                        prime_list[size++] = i;
                        printf("%d\n", i);
                }
        }
 
        return 0;
}

Discussion

Enter your comment (wiki syntax is allowed):
If you can't read the letters on the image, download this .wav file to get them read to you.
 
프로그래밍_기타.txt · 마지막 수정: 2010/01/12 21:23 작성자 pitoosung
 
이 위키의 내용은 다음의 라이센스에 따릅니다 :CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki