I am trying to test the installation of gsl
in my Macbook. I followed instructions from this (1) and this (2) website for the installation of gsl
.
When I try to install gsl
using brew install gsl
, I get the message:
Warning: gsl 2.5 is already installed and up-to-date
But, the above message is not a big cause of worry. To check if gsl
is installed properly, I am trying to compile a test code which is given below (main.c
). I have trouble when I try to compile this code.
#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>
int main( int argc, const char *argv[] ) {
double x = 5.0 ;
double y = gsl_sf_bessel_J0( x ) ;
printf("J0(%g) = % .18e\n", x, y ) ;
return 0 ;
}
I am trying to compile the above code using gcc -Wall -I/usr/local/inlcude main.c
. Below is the error message that I am getting.
Undefined symbols for architecture x86_64:
"_gsl_sf_bessel_J0", referenced from:
_main in ccHCdcTr.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I read the answers given in this stackoverflow post (because it also refers to the aforementioned error ld: symbol(s) not found for architecture x86_64
). And, I tried to compile the code using gcc -m32 -Wall -I/usr/local/inlcude main.c
. But now, I get more errors:
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccrjsmhl.s:
46:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccrjsmhl.s:46:11: note: change section name to "__text"
.section
__TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
Undefined symbols for architecture i386:
"_gsl_sf_bessel_J0", referenced from:
_main in ccAmYmtF.o
ld: symbol(s) not found for architecture i386
collect2: error: ld returned 1 exit status
In both cases, I do not see any object file ( *.o
) in my working directory after compilation. How can I get the above mentioned code to run properly? How can I check if my gsl
is installed correctly? I am working with macOS Mojave Version 10.14.3 .