The library CFITSIO by Bill Pence looked attractive to me, but after a week of sporadic questions to Bryan Irby at Goddard still can not seem to compile a program using the library. For archival purposes, I dump my notes below.
I should note that in the process of compleing these notes I heard some more from Bryan Irby and he got me fixed up. I can compile and run BP's testf77.f code. I'll look this code over and see what I can dig out from it.
This file: /home/sco/CFITSIO/README.cfitsio I made the subdirectory where I want to install the library: % mkdir /home/sco/CFITSIO/cfitsioLIB To make the library: % cp /home/sco/Downloads/cfitsio-3.49.tar.gz . % tar xvzf cfitsio-3.49.tar.gz % cd cfitsio-3.49/ % ./configure --prefix=/home/sco/CFITSIO/cfitsioLIB % make % make % make shared % make install % make testprog *** thta last step fails ......... Here is what I get: % ls /home/sco/CFITSIO/cfitsioLIB include/ lib/ % ls /home/sco/CFITSIO/cfitsioLIB/lib libcfitsio.a libcfitsio.so@ libcfitsio.so.9@ libcfitsio.so.9.3.49* pkgconfig/ % ls /home/sco/CFITSIO/cfitsioLIB/include/ drvrsmem.h fitsio2.h fitsio.h longnam.h The next thing to do is to see how I write a gfortan code to use this library. ============================================ http://heasarc.gsfc.nasa.gov/cgi-bin/ftoolshelp Hello: I have just downloaded cfitsio-3.49.tar.gz and installed the library but the test program does not seem to compile: The library seems to mmake and install properly: % /home/sco/CFITSIO/cfitsio-3.49 % echo $LD_LIBRARY_PATH /home/sco/CFITSIO/cfitsioLIB % ls $LD_LIBRARY_PATH include/ lib/ However, when I run the testprog: % make testprog **** Many line, but at the end I see: /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1954: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1956: undefined reference to `curl_easy_perform' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1970: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1972: undefined reference to `curl_easy_perform' collect2: error: ld returned 1 exit status Makefile:147: recipe for target 'testprog' failed make: *** [testprog] Error 1 Can you give me any advice on how to make this work? Thanks, Steve Odewahn ============================================ Hi Bryan: I deleted renamed the original tar dump and the do: % tar xvzf cfitsio-3.49.tar.gz % cd cfitsio-3.49/ % ./configure --prefix=/home/sco/CFITSIO/cfitsioLIB % make >& make1.txt % make >& make2.txt % make install >& make3.txt % make testprog >& make4.txt cd /home/sco/CFITSIO/cfitsio-3.49 I attach the 44 make?.txt files. Thanks, Steve Tue Aug 18 11:05:00 CDT 2020 ============================ New note from Bryan Irby: Hi Steve, I'm still puzzling over this, but I think it must have to do with the curl installation found by the CFITSIO configure: it appears to have chosen / home/sco/anaconda2/bin/curl-config, and for some reason the libcurl provided by the output from that curl-config isn't behaving as expected. I would expect to see that the output from $ ldd libcfitsio.so shows a baked-in link to something like /home/sco/anaconda2/lib/libcurl.so, such that libcfitsio.so brings in libcurl.so and testprog doesn't have to resolve any curl symbols itself. But it doesn't appear to be, so I'm confused. If you have curl installed on your system (e.g. 'sudo apt-get -y install libcurl4 libcurl4-gnutls-dev'), you could try putting /usr/bin at the front of your path (ahead of the anaconda path) and then re-configure and re-build cfitsio to see if that fixes it. Bryan --- Bryan Irby (Innovim, LLC) HEASARC Software NASA/GSFC, Code 660.4 Greenbelt, Maryland 20771 USA bryan.k.irby@nasa.gov ================== Here are my efforts today. Do I have curl installed? Answer: Yes. % which curl /home/sco/anaconda2/bin/curl If I put /usr/bin ahead of anaconda, do I get a differnet curl? % echo $PATH /home/sco/binpub:/usr/bin:/home/sco/anaconda2/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/home/sco/Installs/install_sco2019_20200305/bin/bini:/home/sco/Installs/install_sco2019_20200305/bin/python:/home/sco/Installs/install_sco2019_20200305/bin/binc/otw:/snap/bin:/home/sco/Installs/install_sco2019_20200305/bin/bini:/home/sco/Installs/install_sco2019_20200305/bin/binc/otw:/home/sco/Installs/install_sco2019_20200305/bin/binc/morpho:. % which curl /home/sco/anaconda2/bin/curl # I still "see" the same anaconda curl So, I install the curl that Bryan suggests: % sudo apt-get -y install libcurl4 libcurl4-gnutls-dev % which curl /home/sco/anaconda2/bin/curl % csh .cshrc % rehash % echo $PATH /home/sco/binpub:/usr/bin:/home/sco/anaconda2/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/home/sco/Installs/install_sco2019_20200305/bin/bini:/home/sco/Installs/install_sco2019_20200305/bin/python:/home/sco/Installs/install_sco2019_20200305/bin/binc/otw:/snap/bin:/home/sco/Installs/install_sco2019_20200305/bin/bini:/home/sco/Installs/install_sco2019_20200305/bin/binc/otw:/home/sco/Installs/install_sco2019_20200305/bin/binc/morpho:. % which curl /home/sco/anaconda2/bin/curl So, I am always seeing the anaconda curl!!! % find / -name 'curl.h' -print >&a1 /home/sco/anaconda2/pkgs/libcurl-7.64.0-h20c2e04_2/include/curl/curl.h /home/sco/anaconda2/include/curl/curl.h /usr/include/x86_64-linux-gnu/curl/curl.h So, maybe I put /usr/include up front? % echo $PATH /home/sco/binpub:/usr/bin:/usr/include:/home/sco/anaconda2/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/home/sco/Installs/install_sco2019_20200305/bin/bini:/home/sco/Installs/install_sco2019_20200305/bin/python:/home/sco/Installs/install_sco2019_20200305/bin/binc/otw:/snap/bin:/home/sco/Installs/install_sco2019_20200305/bin/bini:/home/sco/Installs/install_sco2019_20200305/bin/binc/otw:/home/sco/Installs/install_sco2019_20200305/bin/binc/morpho:. % which curl /home/sco/anaconda2/bin/curl Fri Aug 21 10:42:10 CDT 2020 ============================ I got a note from Bryan that seems to say I don;t really need curl installed, I need a library that curl uses. Presumamly this is whay he had the extra flags on the apt command: % sudo apt-get -y install libcurl4 libcurl4-gnutls-dev After this, I tried the "make tesprog" and go the same errors about undefined references to clurl routines. Before I close the book on this, I clean all om subdirectories and start freh. I unpack the tar file and build a new destination subdirectory for the cfitsio library and give everything a try once again. % pwd /home/sco/CFITSIO % ls cfitsio-3.49.tar.gz S/ % echo $PATH /home/sco/binpub:/usr/bin:/usr/include:/home/sco/anaconda2/bin:/bin:/usr/local/sbin:/usr/local/bin:.... % sudo apt-get -y install libcurl4 libcurl4-gnutls-dev % mkdir /home/sco/CFITSIO/cfitsioLIB % ls cfitsio-3.49.tar.gz cfitsioLIB/ S/ % tar xvzf cfitsio-3.49.tar.gz % cd cfitsio-3.49/ % ./configure --prefix=/home/sco/CFITSIO/cfitsioLIB Congratulations, Makefile update was successful. You may want to run "make" now. % make >& make1.txt % make >& make2.txt % make install >& make3.txt % make testprog >& make4.txt % tail make4.txt **** make4.txt doen NOT contain the error messages about about curl! % ls testprog testprog* When I run it, there is a huge output, and then: Normally, there should be 8 error messages on the stack all regarding 'numerical overflows': Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. Status = 0: OK - no error >>>> As far as I can tell, the lbrary is intsalled and the testprog code runs correctly. ====================================================== BUT, the testf77 code will not compile: Hi Bryan: One last thing, and then I'll give up. The next code that Bill Pence gives is a fortran code name "testf77.f". I tyr to compile it, and I get the same errors about curl!!!! If you see a quick fix, I'll give a try. Here is what I do: % ls makefile testf77.f % cat makefile # FC = gfortran FFLAGS= -O -ffixed-line-length-none -fno-automatic LIB0 = $(OTWLIB_DIR)/OTWLIB.a LIB1 = /home/sco/CFITSIO/cfitsioLIB/lib/libcfitsio.a ## OBJS = \ testf77.o testf77: $(OBJS) $(FC) -o testf77 $(FFLAGS) $(OBJS) $(LIB0) $(LIB1) -L$(X11_DIR) -lX11 % make gfortran -o testf77 -O -ffixed-line-length-none -fno-automatic testf77.o /home/sco/Installs/install_sco2019_20200305/codes/fortran/gfortran_compiler/libs/LIN/OTWLIB.a /home/sco/CFITSIO/cfitsioLIB/lib/libcfitsio.a -L -lX11 /home/sco/CFITSIO/cfitsioLIB/lib/libcfitsio.a(cfileio.o): In function `ffihtps': /home/sco/CFITSIO/cfitsio-3.49/cfileio.c:7945: undefined reference to `curl_global_init' /home/sco/CFITSIO/cfitsioLIB/lib/libcfitsio.a(cfileio.o): In function `ffchtps': /home/sco/CFITSIO/cfitsio-3.49/cfileio.c:7958: undefined reference to `curl_global_cleanup' /home/sco/CFITSIO/cfitsioLIB/lib/libcfitsio.a(drvrnet.o): In function `ssl_get_with_curl': /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1860: undefined reference to `curl_easy_init' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1862: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1869: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1871: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1872: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1874: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsioLIB/lib/libcfitsio.a(drvrnet.o):/home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1878: more undefined references to `curl_easy_setopt' follow /home/sco/CFITSIO/cfitsioLIB/lib/libcfitsio.a(drvrnet.o): In function `ssl_get_with_curl': /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1918: undefined reference to `curl_easy_perform' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:2056: undefined reference to `curl_easy_cleanup' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1892: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1893: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1894: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:2017: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:2018: undefined reference to `curl_easy_perform' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:2025: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:2026: undefined reference to `curl_easy_perform' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:2045: undefined reference to `curl_easy_cleanup' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1944: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1945: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1947: undefined reference to `curl_easy_perform' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1954: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1956: undefined reference to `curl_easy_perform' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1970: undefined reference to `curl_easy_setopt' /home/sco/CFITSIO/cfitsio-3.49/drvrnet.c:1972: undefined reference to `curl_easy_perform' collect2: error: ld returned 1 exit status makefile:10: recipe for target 'testf77' failed make: *** [testf77] Error 1 Maybe I have to refeernce a library for curl explicitly, but I have no idea how to find that. May be a case of death by shared libraby. Thanks, Steve Odewahn -------------------------------------------- Answer from Bryan: Hi Steve, As I mentioned before, the shared libcfitsio (the .so) should pull in the libcurl dependency automatically, but if you use the static one (libcfitsio.a), you have to link with libcurl to resolve that dependency. So, you either need to add -lcurl to your link line (like you have with -lX11), or you should change "LIB1" to point to the shared libcfitsio.so instead. Bryan So I change my makefile to: % cat makefile # FC = gfortran FFLAGS= -O -ffixed-line-length-none -fno-automatic LIB0 = $(OTWLIB_DIR)/OTWLIB.a LIB1 = /home/sco/CFITSIO/cfitsioLIB/lib/libcfitsio.a ## OBJS = \ testf77.o testf77: $(OBJS) $(FC) -o testf77 $(FFLAGS) $(OBJS) $(LIB0) $(LIB1) -lcurl -L$(X11_DIR) -lX11 % make gfortran -o testf77 -O -ffixed-line-length-none -fno-automatic testf77.o /home/sco/Installs/install_sco2019_20200305/codes/fortran/gfortran_compiler/libs/LIN/OTWLIB.a /home/sco/CFITSIO/cfitsioLIB/lib/libcfitsio.a -lcurl -L -lX11 % ls makefile testf77* testf77.f testf77.o Following the example of page 6 of Bill's pdf (% evince /home/sco/CFITSIO/S/cfitsio.pdf): % cp ../cfitsio-3.49/testf77.out . % ls makefile testf77* testf77.f testf77.o testf77.out % testf77 > testf77.lis % wc -l testf77.lis 746 testf77.lis % wc -l testf77.out 746 testf77.out % date >a.1 % cp a.1 b.1 % diff a.1 b.1 ***** So files the same produce no output When I do this, I also get no output in the diff1 file. % diff testf77.lis testf77.out > diff1 **** Looks like testf77* runs properly. Hi Bryan: Thanks a million for the super-fast reply. The "-lcurl" solution works and I get a testf77 execuatble that runs and produces output that matched Bill's file testf77.out. Thanks very much for the help. Cheers, SteveO