OpenSSL 라이브러리를 빌드하려고 한다.

자료는 Qt wiki에서 제공하는 "Compiling OpenSSL with MinGW" 을 참고하려한다.

링크 -> https://wiki.qt.io/Compiling_OpenSSL_with_MinGW

 

빌드는 MSYS2에서 진행한다.

MSYS2란?

https://wikidocs.net/book/13025

 

MSYS2 Documentation

## [MSYS2](https://www.msys2.org/) ### MSYS2의 Documentation 부분을 번역한 자료입니다번역 : 브리티쉬 MSYS2는 기본 …

wikidocs.net

 

./Configure

No C compiler found

 

컴파일러가 없다. 컴파일러를 설치한다.

32bit

# pacman -S mingw-w64-i686-gcc

64bit

# pacman -S mingw-w64-x86_64-gcc

 

환경변수 설정

# export PATH="/c/Program Files/msys64/mingw32/bin:$PATH"

 

설정된 gcc 확인

# which gcc

32bit gcc

 

Configure 실행

./Configure --prefix=$PWD/dist no-idea no-mdc2 no-rc5 shared mingw

 

 

설치

make depend && make && make install

building

테스트 코드(정적 라이브러리 libcrypto.a)

#include <iostream>
#include "include/openssl/rand.h"
using namespace std;

int main(int argc, char const *argv[])
{
    /* code */
    unsigned char arr[32] = {0x00, };
    RAND_bytes(arr, 32);

    for (size_t i = 0; i < 32; i++)
    {
        printf("%02x ", arr[i]);
    }
    cout << endl;
    
    return 0;
}

 

실행

g++ main.cpp -L. -lcrypto

 

결과

 

에러#1

 

기존에 설치되어 있는 mingw-w64-x86_64-gettext로 인한 에러, 삭제 후 다시 재설치

+ Recent posts