OCaml 개발환경을 Windows에서 설정하기
Written By Jay Lee
2021-03-06
OCaml 개발 환경을 설정하는 방법은 1. OcaIDE 플러그인을 사용하는 방법과, 2. Windows Subsystem for Linux를 사용하는 방법이 있습니다. 2번 방법은 가상화된 Linux를 이용하는 방법으로, 기본적으로 Linux 명령어를 숙지하고 있거나, 공부를 하고자 하는 학생에게 추천합니다. (OcaIDE는 2021년 8월에 지원종료)
각자 맞는 방법을 사용하시기 바랍니다.
설치 중에 문제가 있을 경우에 대비하여 대응 방법 몇 가지를 Troubleshooting에 작성해 두었습니다. 만약 그럼에도 불구하고 설치에 어려움을 겪을 경우, 조교 이메일로 ( astean1001@gmail.com ) 연락 주시면 적절한 답변을 드리거나, 적절한 시간을 잡아 연구실에서 직접 만나 도움을 드릴 수 있습니다.
1. Eclipse + OcaIDE Plugin을 이용한 방법 1. Eclipse 다운로드 페이지 에서 Windows용 Eclipse Installer를 다운받아 설치
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
2. Eclipse Installer에서 Eclipse IDE for Java Developers 선택하여 설치
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
3. OCaml for Windows 에서 자신의 OS 버전에 맞는 Graphical Installer를 다운받아 설치 4. OCaml for Windows 설치 완료 후, Eclipse IDE 실행
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
5. 상단 메뉴바에서 Help > Eclipse Marketpalce … 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
6. Eclipse Marketplace의 Search 탭에서 Find 칸에 Ocaml 검색 7. OcalIDE 플러그인 Install 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
8. 경고창이 나오는 경우 Install anyway 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
9. Eclipse 재실행 후 우측 상단 낙타 버튼 클릭 시, 위의 스크린샷과 같은 Ocaml Toplevel 탭 구성을 볼 수 있음. (보이지 않을 시에 Troubleshooting 단락 참조)
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
10. 작업 표시줄의 검색창에 cygwin을 검색하고 Cygwin64 Terminal 을 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
11. Cygwin64 Terminal에서 opam install ocamlbuild
입력
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
12. 다시 Eclipse IDE로 돌아와서 상단 메뉴바에서 Window > Preferences 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
13. Preferences의 우측 탭에 OcaIDE > Paths 선택
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
14. 각각의 경로를 다음과 같이 채움. (Browse를 클릭해 경로를 찾아가면 됨.) * OCaml Binaries Directory : `C:\OCaml64\home\[사용자_윈도우_아이디]\.opam\4.11.1+mingw64c\bin`
* ocaml binaries (ocaml ~ ocamlbuild) : `C:\OCaml64\home\[사용자_윈도우_아이디]\.opam\4.11.1+mingw64c\bin\ocaml(c, opt, dep, ...).exe`
* OCaml lib path : `C:\OCaml64\home\[사용자_윈도우_아이디]\.opam\4.11.1+mingw64c\lib\ocaml`
15. OCaml Binaries Directory 칸의 Apply 클릭 후, Apply and Close 클릭.
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
경로 설정 이후 하단의 Ocaml Toplevel 탭에서 새로고침 버튼을 눌러 다음과 같이 정상적으로 Ocaml 인터프리터가 작동하는지 확인
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
16. 상단 메뉴 바의 File > New > OCaml Managed Project 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
17. Project Name 설정 후 Finish 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
18. Navigator 탭의 프로젝트 폴더에 우클릭 > New > Module 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
19. File name 설정 (여기서는 test이므로 test.ml이 생성)후 Finish 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
20. test.ml에 위와 같이 입력
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
21. Navigator 탭의 프로젝트 폴더에 우클릭 > Properties 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
22. Properties for … 의 Ocaml Project 탭에서 Make executable for test.ml의 체크박스를 체크
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
23. 상단 메뉴 바의 Project > Build Project 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
24. test.ml의 모든 코드를 선택한 후 우클릭 > Load in Toplevel 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
25. 하단 Ocaml Toplevel 창에서 실행 결과 확인 (실행이 안될 시, Troubleshooting 참조) 2. WSL (Windows Subsystem for Linux)를 이용한 방법
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
1. Windows의 설정 > 업데이트 및 보안 > 개발자용에서 개발자 모드 설정
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
2. 제어판에서 프로그램 및 기능 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
3. 프로그램 및 기능에서 Windows 기능 켜기/끄기 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
4. Windows 기능 켜기/끄기에서 Linux용 Windows 하위 시스템 체크 후 확인 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
5. 작업 표시줄의 검색창에서 Microsoft Store를 검색하여 이동
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
6. Microsoft Store의 검색창에 Ubuntu 입력
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
7. 검색 결과 중 Ubuntu 클릭하여 상세 페이지에서 설치 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
8. 설치 완료 후 실행 클릭 시에 다음과 같은 창이 뜸. 대기.
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
9. 사용자명과 패스워드를 세팅한 후, 다음의 명령어들을 순차적으로 입력 (Y/n을 묻는 글귀가 나오면 Y를 입력후 엔터)
sudo apt-get update
sudo apt-get install ocaml
sudo apt-get install opam
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
10. 아무 원하는 코드 편집기로 (VS Code, Sublime text, vim, whatever..) 위의 코드를 작성하여 원하는 경로에 test.ml로 저장
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
11. Ubuntu Terminal에서 cd /mnt/c
를 입력하여 C 드라이브로 이동하고, test.ml을 저장한 경로로 이동한 후, ocaml test.ml 입력하여 결과가 다음과 같이 나오는 지 확인. 12. 상태 표시창의 검색창에 Ubuntu를 검색하여 Ubuntu 앱을 켜는 것으로 사용 가능. 3. Troubleshooting 낙타 버튼이 없습니다
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
상단 메뉴바의 Window > Perspective > Open Perspective를 클릭
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Open Perspective에서 OCaml을 클릭한 후 확인 클릭
낙타 버튼과 함께 위의 Ocaml 창들이 모두 나타납니다.
Load in Toplevel을 했는데, cannot find ***.cmo라고 나옵니다 OCaml 버전의 문제인지, 간혹 load "****.cmo"가 작동하지 않을 때가 있습니다.
#cd "C:\\Users\\username\\eclipse-workspace\\test\\";;
#load ".\\test.cmo";;
를 직접 OCaml Toplevel의 입력창에 입력한 후 엔터를 치면 결과를 확인할 수 있습니다.
경로에 상대경로 표시인 .\가 없어서 찾지 못하는 경우입니다.