Menu

#141 Cannot include healpix headers in my own C++ code

v3.82+
open
nobody
None
5
2024-07-01
2024-06-30
Anonymous
No

I am trying to use HEALPix in C++ codes. I have run the configuration file using ./configure --auto=cxx and then run " make cpp-all". Initially, it showed an error saying "libtool: error: require no space between '-L' and '-lcfitsio' ". Hence I removed the -L from the make file. After that I could compile. The make cpp-test says pass as well (screenshot attached as "Healpix_Install.png). However, I am unable to include it in my .cpp codes. I have also defined environment variable "HEALPIX" in bashrc. I am unable to include the healpix modules in my code (screenshot of error attached as Healpix_Err.png). Thanks in advance.

2 Attachments

Discussion

  • Martin Reinecke

    Martin Reinecke - 2024-07-01

    I think that the installation actually went fine. But the command "make Test -lhealpix_cxx" will not work in practice - you cannot pass compilation and linker flags to "make" in this way.
    The command(s) that must be executed (with the help of "make" or in a different way is:

    g++ Test_cpp -I /home/medha/Programs/Healpix_3.82/include -L /home/medha/Programs/Healpix_3.82/lib -lhealpix_cxx (combined compilation and linking)

    or (separate compilation and linking):

    g++ Test.cpp -c -I /home/medha/Programs/Healpix_3.82/include
    g++ Test.o -o Test -L /home/medha/Programs/Healpix_3.82/lib -lhealpix_cxx

    I may have overlooked some details in the commands above, but that's the rough approch.

    Unfortunately working with "make" and compiling C++ programs (especially when they depend on other libraries) has quite some learning curve, but in my opinion it's very much worth the effort!

     

    Last edit: Martin Reinecke 2024-07-01
  • Anonymous

    Anonymous - 2024-07-01

    Dear Martin,

    It works. Thank you very much.

     
  • Anonymous

    Anonymous - 2024-07-01

    Dear Martin, Also is there any way I could add it to bashrc or something by which I would not have to used the -I and the -L options?

     
  • Martin Reinecke

    Martin Reinecke - 2024-07-01

    I wouldn't recommend doing this, since this approach will become unmaintainable once you have more complicated projects. My recommendation is to learn a bit about Makefiles (or about cmake or other alternatives if you prefer) and add the appropriate Makefile or other to your code directory. Then a simple "make" will always do the expected thing, and you do not need to change global configuration files.

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB