Programming/C
[sqllite3] sqlcipher build for Windows
Tribal
2018. 10. 23. 15:58
sqlcipher github : https://github.com/sqlcipher/sqlcipher
- Windows에서 말로는 빌드하기 어렵다는데, 빌드 자료를 재정리해준 사람이 많아서 별로 어렵진 않다.
- 기존 sqlite3는 헤더에서 sqlite3_key를 명시만 하고, 상업 관련때문에 구현은 안 되어 있음. 따라서 sqlite를 암호화하려면 이런게 필요
사전 설치
- Visual Studio 2015 or 2017
- vcpkg (openssl build 같은 방법으로 라이브러리를 얻을 수 있으면 필요 없음)
빌드 방법(설명은 32bit binary build, 64bit는 일부 과정을 수정해서 사용)
- git clone https://github.com/sqlcipher/sqlcipher로 받아옴
- vcpkg install openssl:x86-windows openssl:x64-windows로 libeay32.lib, libeay32.dll 획득(사전 설치에서 말했듯이 따로 방법있으면 안 해도 됨)
- libeay32.lib과 libeay32.dll을 sqlcipher 폴더에 복사
- vcpkg의 installed 폴더의 x86-windows 폴더를 c 드라이버 경로로 복사 후, opensslbuild32로 이름 변경(경로 잘 파악하고 있다면 안 해도 됨)
- http://www.mingw.org/의 왼쪽 download/installer를 클릭해 mingw 설치
- 아래 사진처럼 Basic Setup을 클릭 후, 오른쪽 Package가 설치(Mark Install => Installation => Apply Change => Apply)
- 아래 사진처럼 All Packages 클릭 후, 오른쪽 Package 목록 중 tcl 6개 항목을 전부 설치(Mark Install => Installation => Apply Change => Apply)
- 'C:\MinGW\msys\1.0' 경로의 msys.bat 실행
- cd /c 로 이동해서 sqlcipher 폴더까지 이동 (ls / 하면 안 보이는데, 걍 무시해도 됨)
아래의 커맨드를 수정해서 입력(4번 과정대로 이름 변경했으면, 걍 수정없이 복붙해도 됨)
12# -I/c 부분 경로를 openssl 경로로 수정$ ./configure --with-crypto-lib=none --disable-tcl CFLAGS="-DSQLITE_HAS_CODEC -DSQLCIPHER_CRYPTO_OPENSSL -I/c/opensslbuild32/include /c/sqlcipher/libeay32.dll -L/c/sqlcipher/ -static-libgcc" LDFLAGS="-leay32"cs - 아래 커맨드를 차례대로 입력해서 컴파일1234$ make clean$ make sqlite3.c$ make$ make dll
cs - 현재 디렉토리에 sqlite.dll 생성 완료
※ dll이 아니라 lib가 필요한 경우, Visual Studio 명령 프롬프트를 사용해서 변환(참고 자료 1번째꺼 참고)하면 된다.
Visual Studio에 로드 방법(아직 미추가, 참고 자료 3번째꺼 참고)
참고 자료
- 글만 있지만 자세함 : http://shiny823.blogspot.com/
- 위의 링크 참고 자료 : http://www.jerryrw.com/howtocompile.php
- Windows build original : https://groups.google.com/forum/#!topic/sqlcipher/VcYpa1a_RTM