Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

Astro Coke

[C/C++] Install GSL library for icc in Mac OS 본문

Computer Setup

[C/C++] Install GSL library for icc in Mac OS

astrodoo 2019. 4. 11. 00:02

gsl 은 c/c++ 의 science/math 패키지이다.

homebrew 등을 이용하여 간단하게 설치할 수도 있지만

icc compiler 환경으로 인스톨을 하기 위해서는 소스파일을 컴파일하는 방법이 있다.

 

우선 최신 버전의 패키지를 

https://www.gnu.org/software/gsl/

 

에서 다운을 받은 후 압축을 풀고 폴더로 가서 다음과 같이 설정 후 설치한다.

 

> export CC=icc

> CFLAGS="-O2 -m64 -mieee-fp -march=core2 -mtune=core2 -Wpointer-arith -fno-strict-aliasing "; export CFLAGS

> ./configure

> make

 

설치 후 테스트는 다음과 같다.

 

> make --jobs=4

> make check

 

모든 과정이 순조롭다면 다음의 테스트 파일로 간단히 체크할 수도 있다.

 

================= test_gsl.cpp ==================

#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int main (void)
{
  double x, y;
  x = 5.0;
  y = gsl_sf_bessel_J0 (x);
  printf ("J0(%g) = %.18e\n", x, y);
  return 0;
}
===============================================

 

> icc -L /opt/local/lib -lgsl -lgslcblas -I /opt/local/include test_gsl.cpp

> ./a.out

 

J0(5) = -1.775967713143382642e-01

 

혹은

 

> icc -I /opt/local/include -c -o test_gs1.o test_gsl.cpp

> icc -L /opt/local/lib -lgsl -lgslcblas -o test test_gsl.o