mweastwood / LibHealpix.jl

A Julia wrapper of the Healpix library.
http://mweastwood.info/LibHealpix.jl/stable/
Other
11 stars 7 forks source link

better build system and healpix v3.30 #14

Closed mweastwood closed 8 years ago

mweastwood commented 8 years ago

I'm going to leave the really messy commit history to help remind me why things are the way they are.

BinDeps is a nice idea and maybe it even works but the documentation is out-of-date and incomplete. I found that I couldn't set a static library as a build dependency. As far as I can tell this is because it relies on dlopen to test for the library's existence which you can't do to a static library. So I gave up trying to trick BinDeps into finding system libraries and installing everything correctly. Instead I've rolled my own custom build script that seems to work on my linux box, an old macbook, and Travis. It's not the most resilient script but it's definitely better than what we had before.

I decided to remove the -fno-tree-fre flag while building Healpix. Clang doesn't know about this flag and so it was creating errors on OSX Travis (strangely the old macbook seemed to be happy enough but I might have just missed the warnings). This flag is used by the default Healpix configuration files so its removal might have performance implications.

Finally we've updated to Healpix v.3.30.

@pochoi Can you give this a try? Let me know if you hit any errors.

pochoi commented 8 years ago

Hi. I will try it tonight.

Actually I was trying to build Healpix C++ library with autoreconf. Peeking into healpix.rb homebrew-science/healpix.rb, it may be something like

cd src/cxx/autotools
autoreconf --install
./configure --prefix=good prefix
make install

Then, it may be possible to compile your c++ wrapper with pkg-config: http://healpix.sourceforge.net/html/install.htm#SECTION00070000000000000000

mweastwood commented 8 years ago

Oh wow that is a lot easier than what I've been doing. Why would they have multiple ways to build their library? Seems silly.

pochoi commented 8 years ago

I guess it is the way so that Healpix can be built with a reasonable compiler. Healpy also uses those building tools like autoconf and pkg-conf to build the libraries. https://github.com/healpy/healpy/blob/a089083d16c0524f57bd339bad892ac22a9e7b74/setup.py#L140-L146

pochoi commented 8 years ago

It seems some tweaks are need to generate correct flags by pkg-config to compile the wrapper. The libraries are not found when compiling the wrapper.

I tried to put an absolute path of the .pc files. Somehow I got it works for OSX, but not Linux. The file libhealpixwrapper.so is already generated, but the travis linux machine complaints that /home/travis/.julia/v0.4/LibHealpix/src/../deps/usr/lib/libhealpixwrapper: cannot open shared object file: No such file or directory. Weird...

15

mweastwood commented 8 years ago

I didn't finish debugging this on Friday, but the reason I took my approach is to handle the case where healpix is installed in a system path. In that case you want to add deps/usr/lib to pkg-config's search path instead of hard coding the location of the .pc file.

It looks like the Linux build is having rpath issues. That last commit fixed it locally for me so I'm not sure what the problem is on Travis now.

mweastwood commented 8 years ago

Yes! Success.

The final problem was that if you use autotools to build healpix you get libhealpix_cxx.a and libhealpix_cxx.so whereas before we were just getting the former. The linker seems to prefer the shared library so we need to dlopen it before libhealpixwrapper.so.