Problems with TFITSHDU

I wrote a code to read .fits files. I want to compile it.
I include the TFITS.h file.

and compile it

g++ fits_time.cxx root-config --libs --cflags -o readfits

Then it has the error:
fits_time.cxx: In function ‘int main(int, char**)’:
fits_time.cxx:38: warning: converting to ‘int’ from ‘double’
fits_time.cxx:39: warning: converting to ‘int’ from ‘double’
/tmp/ccb834Li.o: In function main': fits_time.cxx:(.text+0x164): undefined reference toTFITSHDU::TFITSHDU(char const*)’
fits_time.cxx:(.text+0x1e9): undefined reference to `TFITSHDU::GetArrayColumn(unsigned int)’

How to solve this “undefined reference” ?
fits_time.cxx (1.38 KB)

Hi,

You have to link with libFITSIO. Simply add -lFITSIO to the list of libraries: root-config --libs -lFITSIO

Cheers, Bertrand.

I tried this compile command
g++ fits_time.cxx root-config --libs -IFITSIO -o readfits
But it became even more errors:
"
Unknown argument “-IFITSIO”!
Usage: root-config [–prefix[=DIR]] [–exec-prefix[=DIR]] [–version] [–cflags] [–auxcflags] [–ldflags] [–new] [–nonew] [–libs] [–glibs] [–evelibs] [–bindir] [–libdir] [–incdir] [–etcdir] [–noauxcflags] [–noauxlibs] [–noldflags] [–has-] [–arch] [–platform] [–dicttype] [–config] [–features] [–svn-revision] [–python-version] [–cc] [–cxx] [–f77] [–ld ] [–help]
fits_time.cxx:11:19: error: TFile.h: No such file or directory
fits_time.cxx:12:19: error: TTree.h: No such file or directory
fits_time.cxx:13:22: error: TProfile.h: No such file or directory
fits_time.cxx:14:21: error: TCanvas.h: No such file or directory
fits_time.cxx:15:21: error: TString.h: No such file or directory

"

What is going on?

root-config --cxx --cflags -o readfits fits_time.cxx root-config --libs -lFITSIO

Now I tried this command to compile,
g++ fits_time.cxx root-config --libs --cflags -o fits_time ~/ProgramFiles/root-v5-32-00/lib/libFITSIO.so
There is no error when compiling. But when I run the program, there is this error:

Illegal instruction: 4

How to solve this?

Your “Double_t Array[4146][2160];” is more than 68MB long -> see, for example: [url]No error when macro crashes