[C/C++] Install GSL library for icc in Mac OS
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