HealPix与OS X上的c ++代码链接

时间:2014-04-17 14:02:31

标签: c++ macos x86-64 ld

我已经在运行OS X 10.9.2的MacBookPro上成功安装并测试了HealPix 3.11。 在配置脚本中,我选择了'cxx'和'osx'。 现在我正在尝试链接到C ++程序中的HealPix库并获得以下链接错误:

make
g++ -o./test.o -I/Users/kruip/Software/Bonn/plugins/Healpix_3.11/src/cxx/osx/include -c test.cpp
g++ test.o -o test  -lm -L/Users/kruip/Software/Bonn/plugins/Healpix_3.11/src/cxx/osx/lib -lhealpix_cxx -lgslcblas -lgsl
Undefined symbols for architecture x86_64:
  "equal_nocase(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      string2HealpixScheme(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libhealpix_cxx.dylib(healpix_tables.o)
  "planck_failure__(char const*, int, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      string2HealpixScheme(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libhealpix_cxx.dylib(healpix_tables.o)
  "planck_failure__(char const*, int, char const*, char const*)", referenced from:
      T_Healpix_Base<int>::query_multidisc_general(arr<vec3_t<double> > const&, arr<double> const&, bool, std::__1::vector<int, std::__1::allocator<int> > const&, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::Set(int, Healpix_Ordering_Scheme) in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::query_strip_internal(double, double, bool, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      rangeset<int>::append(int const&, int const&) in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::xyf2ring(int, int, int) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::loc2pix(double, double, double, bool) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::pix2loc(int, double&, double&, double&, bool&) const in libhealpix_cxx.dylib(healpix_base.o)
      ...
  "find_enclosing_circle(arr<vec3_t<double> > const&, vec3_t<double>&, double&)", referenced from:
      void T_Healpix_Base<int>::query_polygon_internal<int>(std::__1::vector<pointing, std::__1::allocator<pointing> > const&, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<long>::query_polygon_internal<int>(std::__1::vector<pointing, std::__1::allocator<pointing> > const&, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<long>::query_polygon_internal<long>(std::__1::vector<pointing, std::__1::allocator<pointing> > const&, int, rangeset<long>&) const in libhealpix_cxx.dylib(healpix_base.o)
  "trim(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      string2HealpixScheme(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libhealpix_cxx.dylib(healpix_tables.o)
  "PlanckError::PlanckError(char const*)", referenced from:
      T_Healpix_Base<int>::query_multidisc_general(arr<vec3_t<double> > const&, arr<double> const&, bool, std::__1::vector<int, std::__1::allocator<int> > const&, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::Set(int, Healpix_Ordering_Scheme) in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::query_strip_internal(double, double, bool, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      rangeset<int>::append(int const&, int const&) in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::xyf2ring(int, int, int) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::loc2pix(double, double, double, bool) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::pix2loc(int, double&, double&, double&, bool&) const in libhealpix_cxx.dylib(healpix_base.o)
      ...
  "PlanckError::PlanckError(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      string2HealpixScheme(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libhealpix_cxx.dylib(healpix_tables.o)
  "PlanckError::~PlanckError()", referenced from:
      T_Healpix_Base<int>::query_multidisc_general(arr<vec3_t<double> > const&, arr<double> const&, bool, std::__1::vector<int, std::__1::allocator<int> > const&, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::Set(int, Healpix_Ordering_Scheme) in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::query_strip_internal(double, double, bool, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      rangeset<int>::append(int const&, int const&) in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::xyf2ring(int, int, int) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::loc2pix(double, double, double, bool) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::pix2loc(int, double&, double&, double&, bool&) const in libhealpix_cxx.dylib(healpix_base.o)
      ...
  "pointing::from_vec3(vec3_t<double> const&)", referenced from:
      void T_Healpix_Base<long>::query_multidisc<long>(arr<vec3_t<double> > const&, arr<double> const&, int, rangeset<long>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<long>::query_multidisc<int>(arr<vec3_t<double> > const&, arr<double> const&, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<int>::query_multidisc<int>(arr<vec3_t<double> > const&, arr<double> const&, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
  "pointing::normalize()", referenced from:
      void T_Healpix_Base<int>::query_disc_internal<int>(pointing, double, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<long>::query_disc_internal<int>(pointing, double, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<long>::query_disc_internal<long>(pointing, double, int, rangeset<long>&) const in libhealpix_cxx.dylib(healpix_base.o)
  "pointing::to_vec3() const", referenced from:
      void T_Healpix_Base<int>::query_disc_internal<int>(pointing, double, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<long>::query_disc_internal<int>(pointing, double, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<int>::query_polygon_internal<int>(std::__1::vector<pointing, std::__1::allocator<pointing> > const&, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<long>::query_polygon_internal<int>(std::__1::vector<pointing, std::__1::allocator<pointing> > const&, int, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<long>::query_disc_internal<long>(pointing, double, int, rangeset<long>&) const in libhealpix_cxx.dylib(healpix_base.o)
      void T_Healpix_Base<long>::query_polygon_internal<long>(std::__1::vector<pointing, std::__1::allocator<pointing> > const&, int, rangeset<long>&) const in libhealpix_cxx.dylib(healpix_base.o)
  "typeinfo for PlanckError", referenced from:
      T_Healpix_Base<int>::query_multidisc_general(arr<vec3_t<double> > const&, arr<double> const&, bool, std::__1::vector<int, std::__1::allocator<int> > const&, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::Set(int, Healpix_Ordering_Scheme) in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::query_strip_internal(double, double, bool, rangeset<int>&) const in libhealpix_cxx.dylib(healpix_base.o)
      rangeset<int>::append(int const&, int const&) in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::xyf2ring(int, int, int) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::loc2pix(double, double, double, bool) const in libhealpix_cxx.dylib(healpix_base.o)
      T_Healpix_Base<int>::pix2loc(int, double&, double&, double&, bool&) const in libhealpix_cxx.dylib(healpix_base.o)
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test] Error 1

此测试代码再现了我的问题:

#include "healpix_base.h"
int main(void){

  Healpix_Base healpix_base_ref(5,RING);

  return 0;
}

我的Makefile看起来像这样:

PLUGINS = /Users/kruip/Software/Bonn/plugins
HEALPIX_PATH = $(PLUGINS)/Healpix_3.11/src/cxx/osx

#COMP = /usr/local/bin/mpic++
COMP = g++
FLAGS = 

MYLIBS = -L${HEALPIX_PATH}/lib -lhealpix_cxx
MYINCLUDE = -I${HEALPIX_PATH}/include

OBJS = test.o

all: test

test: ${OBJS}
    ${COMP} ${OBJS} -o test ${FLAGS} -lm $(MYLIBS) -lgslcblas -lgsl

test.o: test.cpp
    ${COMP} -o./test.o ${MYINCLUDE} -c test.cpp ${FLAGS}

clean:
    rm -rf test.o test

此时非常欢迎建议!

1 个答案:

答案 0 :(得分:0)

通过包含以下链接器调用来修复它:-lhealpix_cxx -lcxxsupport -lsharp -lfftpack -lc_utils -lcfitsio