我已经在运行OS X 10.9.5的Linux和MacBookPro上成功安装并测试了HealPix 3.11。在Mac OS上编译healpix库时,在配置脚本中我选择了' cxx'和' osx'。 注意:在linux系统上它运行得很好。
然而,在我的OS X系统上,当我尝试将它用于我自己的简单healpix示例时,它会编译但不能正确链接。以下是我得到的链接错误:
Scanning dependencies of target garage-diff-sphericaldomain-demo1
[100%] Building CXX object CMakeFiles/bin/garage-diff-sphericaldomain-demo1.dir/src/demos/fft-demos/diff-sphericaldomain-demo1.cxx.o
Linking CXX executable bin/garage-diff-sphericaldomain-demo1
Undefined symbols for architecture x86_64:
"std::string::find_last_not_of(char const*, unsigned long, unsigned long) const", referenced from:
trim(std::string const&) in libcxxsupport.a(string_utils.o)
"std::string::find_first_not_of(char const*, unsigned long, unsigned long) const", referenced from:
trim(std::string const&) in libcxxsupport.a(string_utils.o)
"std::string::find(char const*, unsigned long, unsigned long) const", referenced from:
parse_file(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
parse_cmdline_equalsign(int, char const**, std::vector<std::string, std::allocator<std::string> > const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
"std::string::compare(char const*) const", referenced from:
planck_failure__(char const*, int, char const*, std::string const&) in libcxxsupport.a(error_handling.o)
parse_file(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
parse_cmdline_equalsign(int, char const**, std::vector<std::string, std::allocator<std::string> > const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
parse_words_from_file(std::string const&, std::vector<std::string, std::allocator<std::string> >&) in libcxxsupport.a(string_utils.o)
"std::ctype<char>::_M_widen_init() const", referenced from:
planck_failure__(char const*, int, char const*, std::string const&) in libcxxsupport.a(error_handling.o)
operator<<(std::ostream&, pointing const&) in libcxxsupport.a(pointing.o)
parse_file(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
parse_cmdline_equalsign(int, char const**, std::vector<std::string, std::allocator<std::string> > const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
intToString(long, unsigned long) in libcxxsupport.a(string_utils.o)
"std::istream& std::istream::_M_extract<double>(double&)", referenced from:
void stringToData<double>(std::string const&, double&) in libcxxsupport.a(string_utils.o)
"std::istream& std::istream::_M_extract<long double>(long double&)", referenced from:
void stringToData<long double>(std::string const&, long double&) in libcxxsupport.a(string_utils.o)
"std::istream& std::istream::_M_extract<float>(float&)", referenced from:
void stringToData<float>(std::string const&, float&) in libcxxsupport.a(string_utils.o)
"std::istream& std::istream::_M_extract<unsigned int>(unsigned int&)", referenced from:
void stringToData<unsigned int>(std::string const&, unsigned int&) in libcxxsupport.a(string_utils.o)
"std::istream& std::istream::_M_extract<long>(long&)", referenced from:
void stringToData<long>(std::string const&, long&) in libcxxsupport.a(string_utils.o)
"std::istream& std::istream::_M_extract<unsigned long>(unsigned long&)", referenced from:
void stringToData<unsigned long>(std::string const&, unsigned long&) in libcxxsupport.a(string_utils.o)
"std::istream& std::istream::_M_extract<unsigned short>(unsigned short&)", referenced from:
void stringToData<unsigned short>(std::string const&, unsigned short&) in libcxxsupport.a(string_utils.o)
"std::istream& std::istream::_M_extract<long long>(long long&)", referenced from:
void stringToData<long long>(std::string const&, long long&) in libcxxsupport.a(string_utils.o)
"std::istream& std::istream::_M_extract<unsigned long long>(unsigned long long&)", referenced from:
void stringToData<unsigned long long>(std::string const&, unsigned long long&) in libcxxsupport.a(string_utils.o)
"std::istream::operator>>(int&)", referenced from:
void stringToData<int>(std::string const&, int&) in libcxxsupport.a(string_utils.o)
"std::istream::operator>>(short&)", referenced from:
void stringToData<short>(std::string const&, short&) in libcxxsupport.a(string_utils.o)
"std::ostream::put(char)", referenced from:
planck_failure__(char const*, int, char const*, std::string const&) in libcxxsupport.a(error_handling.o)
operator<<(std::ostream&, pointing const&) in libcxxsupport.a(pointing.o)
parse_file(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
parse_cmdline_equalsign(int, char const**, std::vector<std::string, std::allocator<std::string> > const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
"std::ostream::flush()", referenced from:
planck_failure__(char const*, int, char const*, std::string const&) in libcxxsupport.a(error_handling.o)
operator<<(std::ostream&, pointing const&) in libcxxsupport.a(pointing.o)
parse_file(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
parse_cmdline_equalsign(int, char const**, std::vector<std::string, std::allocator<std::string> > const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
"std::ostream& std::ostream::_M_insert<double>(double)", referenced from:
operator<<(std::ostream&, pointing const&) in libcxxsupport.a(pointing.o)
std::string dataToString<double>(double const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<float>(float const&) in libcxxsupport.a(string_utils.o)
"std::ostream& std::ostream::_M_insert<long double>(long double)", referenced from:
std::string dataToString<long double>(long double const&) in libcxxsupport.a(string_utils.o)
"std::ostream& std::ostream::_M_insert<long>(long)", referenced from:
intToString(long, unsigned long) in libcxxsupport.a(string_utils.o)
std::string dataToString<long>(long const&) in libcxxsupport.a(string_utils.o)
"std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)", referenced from:
std::string dataToString<unsigned long>(unsigned long const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<unsigned short>(unsigned short const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<unsigned int>(unsigned int const&) in libcxxsupport.a(string_utils.o)
"std::ostream& std::ostream::_M_insert<long long>(long long)", referenced from:
std::string dataToString<long long>(long long const&) in libcxxsupport.a(string_utils.o)
"std::ostream& std::ostream::_M_insert<unsigned long long>(unsigned long long)", referenced from:
std::string dataToString<unsigned long long>(unsigned long long const&) in libcxxsupport.a(string_utils.o)
"std::ostream::operator<<(int)", referenced from:
planck_failure__(char const*, int, char const*, std::string const&) in libcxxsupport.a(error_handling.o)
parse_file(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
std::string dataToString<int>(int const&) in libcxxsupport.a(string_utils.o)
"std::ostream::operator<<(short)", referenced from:
std::string dataToString<short>(short const&) in libcxxsupport.a(string_utils.o)
"std::string::_M_leak_hard()", referenced from:
tolower(std::string const&) in libcxxsupport.a(string_utils.o)
"std::string::_Rep::_M_destroy(std::allocator<char> const&)", referenced from:
PlanckError::~PlanckError() in libcxxsupport.a(error_handling.o)
PlanckError::~PlanckError() in libcxxsupport.a(error_handling.o)
planck_failure__(char const*, int, char const*, char const*) in libcxxsupport.a(error_handling.o)
string2HealpixScheme(std::string const&) in libhealpix_cxx.a(healpix_tables.o)
(anonymous namespace)::end_stringToData(std::string const&, char const*, std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >&) in libcxxsupport.a(string_utils.o)
void stringToData<std::string>(std::string const&, std::string&) in libcxxsupport.a(string_utils.o)
void stringToData<bool>(std::string const&, bool&) in libcxxsupport.a(string_utils.o)
...
"std::string::_Rep::_S_empty_rep_storage", referenced from:
PlanckError::~PlanckError() in libcxxsupport.a(error_handling.o)
PlanckError::~PlanckError() in libcxxsupport.a(error_handling.o)
planck_failure__(char const*, int, char const*, char const*) in libcxxsupport.a(error_handling.o)
string2HealpixScheme(std::string const&) in libhealpix_cxx.a(healpix_tables.o)
std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libhealpix_cxx.a(healpix_tables.o)
(anonymous namespace)::end_stringToData(std::string const&, char const*, std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >&) in libcxxsupport.a(string_utils.o)
void stringToData<std::string>(std::string const&, std::string&) in libcxxsupport.a(string_utils.o)
...
"std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)", referenced from:
char* std::string::_S_construct<char*>(char*, char*, std::allocator<char> const&, std::forward_iterator_tag) in libcxxsupport.a(string_utils.o)
"std::string::append(char const*, unsigned long)", referenced from:
std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libhealpix_cxx.a(healpix_tables.o)
std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*) in libhealpix_cxx.a(healpix_tables.o)
(anonymous namespace)::end_stringToData(std::string const&, char const*, std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >&) in libcxxsupport.a(string_utils.o)
void stringToData<bool>(std::string const&, bool&) in libcxxsupport.a(string_utils.o)
void split<float>(std::string const&, std::vector<float, std::allocator<float> >&) in libcxxsupport.a(string_utils.o)
void split<double>(std::string const&, std::vector<double, std::allocator<double> >&) in libcxxsupport.a(string_utils.o)
void split<int>(std::string const&, std::vector<int, std::allocator<int> >&) in libcxxsupport.a(string_utils.o)
...
"std::string::append(std::string const&)", referenced from:
std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libhealpix_cxx.a(healpix_tables.o)
(anonymous namespace)::end_stringToData(std::string const&, char const*, std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >&) in libcxxsupport.a(string_utils.o)
std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in libcxxsupport.a(string_utils.o)
"std::string::assign(char const*, unsigned long)", referenced from:
parse_cmdline_classic(int, char const**, std::vector<std::string, std::allocator<std::string> > const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
parse_cmdline_equalsign(int, char const**, std::vector<std::string, std::allocator<std::string> > const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
"std::string::assign(std::string const&)", referenced from:
void stringToData<std::string>(std::string const&, std::string&) in libcxxsupport.a(string_utils.o)
"VTT for std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >", referenced from:
std::string dataToString<short>(short const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<double>(double const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<long long>(long long const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<long double>(long double const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<unsigned long>(unsigned long const&) in libcxxsupport.a(string_utils.o)
intToString(long, unsigned long) in libcxxsupport.a(string_utils.o)
std::string dataToString<long>(long const&) in libcxxsupport.a(string_utils.o)
...
"vtable for std::basic_filebuf<char, std::char_traits<char> >", referenced from:
parse_file(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
parse_words_from_file(std::string const&, std::vector<std::string, std::allocator<std::string> >&) in libcxxsupport.a(string_utils.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for std::basic_ifstream<char, std::char_traits<char> >", referenced from:
parse_file(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) in libcxxsupport.a(string_utils.o)
parse_words_from_file(std::string const&, std::vector<std::string, std::allocator<std::string> >&) in libcxxsupport.a(string_utils.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for std::basic_streambuf<char, std::char_traits<char> >", referenced from:
void stringToData<long double>(std::string const&, long double&) in libcxxsupport.a(string_utils.o)
void stringToData<double>(std::string const&, double&) in libcxxsupport.a(string_utils.o)
void stringToData<float>(std::string const&, float&) in libcxxsupport.a(string_utils.o)
void stringToData<unsigned long long>(std::string const&, unsigned long long&) in libcxxsupport.a(string_utils.o)
void stringToData<long long>(std::string const&, long long&) in libcxxsupport.a(string_utils.o)
void stringToData<unsigned long>(std::string const&, unsigned long&) in libcxxsupport.a(string_utils.o)
void stringToData<long>(std::string const&, long&) in libcxxsupport.a(string_utils.o)
...
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >", referenced from:
void stringToData<long double>(std::string const&, long double&) in libcxxsupport.a(string_utils.o)
void stringToData<double>(std::string const&, double&) in libcxxsupport.a(string_utils.o)
void stringToData<float>(std::string const&, float&) in libcxxsupport.a(string_utils.o)
void stringToData<unsigned long long>(std::string const&, unsigned long long&) in libcxxsupport.a(string_utils.o)
void stringToData<long long>(std::string const&, long long&) in libcxxsupport.a(string_utils.o)
void stringToData<unsigned long>(std::string const&, unsigned long&) in libcxxsupport.a(string_utils.o)
void stringToData<long>(std::string const&, long&) in libcxxsupport.a(string_utils.o)
...
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >", referenced from:
void stringToData<long double>(std::string const&, long double&) in libcxxsupport.a(string_utils.o)
void stringToData<double>(std::string const&, double&) in libcxxsupport.a(string_utils.o)
void stringToData<float>(std::string const&, float&) in libcxxsupport.a(string_utils.o)
void stringToData<unsigned long long>(std::string const&, unsigned long long&) in libcxxsupport.a(string_utils.o)
void stringToData<long long>(std::string const&, long long&) in libcxxsupport.a(string_utils.o)
void stringToData<unsigned long>(std::string const&, unsigned long&) in libcxxsupport.a(string_utils.o)
void stringToData<long>(std::string const&, long&) in libcxxsupport.a(string_utils.o)
...
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >", referenced from:
std::string dataToString<short>(short const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<double>(double const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<long long>(long long const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<long double>(long double const&) in libcxxsupport.a(string_utils.o)
std::string dataToString<unsigned long>(unsigned long const&) in libcxxsupport.a(string_utils.o)
intToString(long, unsigned long) in libcxxsupport.a(string_utils.o)
std::string dataToString<long>(long const&) in libcxxsupport.a(string_utils.o)
...
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for std::basic_ios<char, std::char_traits<char> >", referenced from:
void stringToData<long double>(std::string const&, long double&) in libcxxsupport.a(string_utils.o)
void stringToData<double>(std::string const&, double&) in libcxxsupport.a(string_utils.o)
void stringToData<float>(std::string const&, float&) in libcxxsupport.a(string_utils.o)
void stringToData<unsigned long long>(std::string const&, unsigned long long&) in libcxxsupport.a(string_utils.o)
void stringToData<long long>(std::string const&, long long&) in libcxxsupport.a(string_utils.o)
void stringToData<unsigned long>(std::string const&, unsigned long&) in libcxxsupport.a(string_utils.o)
void stringToData<long>(std::string const&, long&) in libcxxsupport.a(string_utils.o)
...
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/garage-diff-sphericaldomain-demo1] Error 1
make[1]: *** [CMakeFiles/bin/garage-diff-sphericaldomain-demo1.dir/all] Error 2
make: *** [all] Error 2
此错误仅来自libcxxsupport.a
链接静态库,这非常奇怪。
这是我用来编译程序的FindHealPix.cmake文件的链接。如前所述,我已经能够在linux ubuntu 14.04版本的机器上编译和链接而没有任何问题。
答案 0 :(得分:2)
最后,我找到了一种方法让它发挥作用。
由于在Healpix_3.11库中使用OpenMP
,我开始收到其他类型的错误,我不明白为什么。这个错误看起来像这样:
Undefined symbols for architecture x86_64:
"_GOMP_critical_end", referenced from:
_sharp_execute_job._omp_fn.0 in libsharp.a(sharp.o)
"_GOMP_critical_start", referenced from:
_sharp_execute_job._omp_fn.0 in libsharp.a(sharp.o)
"_GOMP_loop_dynamic_next", referenced from:
_sharp_execute_job._omp_fn.0 in libsharp.a(sharp.o)
_phase2map._omp_fn.2 in libsharp.a(sharp.o)
_map2phase._omp_fn.1 in libsharp.a(sharp.o)
_gauss_legendre_tbl._omp_fn.0 in libsharp.a(sharp_geomhelpers.o)
"_GOMP_loop_dynamic_start", referenced from:
_sharp_execute_job._omp_fn.0 in libsharp.a(sharp.o)
_phase2map._omp_fn.2 in libsharp.a(sharp.o)
_map2phase._omp_fn.1 in libsharp.a(sharp.o)
_gauss_legendre_tbl._omp_fn.0 in libsharp.a(sharp_geomhelpers.o)
"_GOMP_loop_end", referenced from:
_sharp_execute_job._omp_fn.0 in libsharp.a(sharp.o)
_phase2map._omp_fn.2 in libsharp.a(sharp.o)
_map2phase._omp_fn.1 in libsharp.a(sharp.o)
"_GOMP_loop_end_nowait", referenced from:
_gauss_legendre_tbl._omp_fn.0 in libsharp.a(sharp_geomhelpers.o)
"_GOMP_parallel_end", referenced from:
...
但谷歌搜索后,我发现此错误即将发生,因为Clang APPLE编译器不允许使用-fopenmp
标志。因此,我必须找到一种方法来强制我的CMakeLists.txt在我的项目中使用gcc和g ++。
所以,问题在于Clang Mac OS X 10.9.5编译器。以下是一个快速回答的步骤:
gcc
或g++
中的/usr/bin
和/usr/local/bin
编译器分别与gcc-49
和g++-4.9
相关联。 Check here for help. g++
和gcc
编译器而不是APPLE Clang编译器。如果您在运行cmake .
时收到以下消息,则表示您的cmake正在调用Clang。- C编译器标识是AppleClang 5.1.0.5030040
- CXX编译器标识为AppleClang 5.1.0.5030040
project()
行以上的以下行来轻松更改上述行为。在我的看起来像这样:... if(APPLE) SET(CMAKE_C_COMPILER_INIT gcc) SET(CMAKE_CXX_COMPILER_INIT g++) endif(APPLE) project(Healpix) ...
有关CMake Compilers结帐another stackoverflow answer和Change CMake compiler/tools的更多帮助。
编辑:
要运行测试示例,例如this one,您可以使用终端命令行:
g ++ healpix-demo1.cxx -I / usr / local / opt / cfitsio / include -I /用户/ gsingh /编程/车库/第三方/ Healpix_3.11 / src目录/ CXX / c_utils -I /用户/ gsingh /编程/车库/第三方/ Healpix_3.11 / src目录/ CXX / libfftpack -I /用户/ gsingh /编程/车库/第三方/ Healpix_3.11 / src目录/ CXX / libsharp -I /用户/ gsingh /编程/车库/第三方/ Healpix_3.11 / src目录/ CXX / cxxsupport -I /用户/ gsingh /编程/车库/第三方/ Healpix_3.11 / src目录/ CXX / Healpix_cxx -L。 -L /用户/ gsingh /编程/车库/第三方/ Healpix_3.11 / src目录/ CXX / OSX / lib目录 -fopenmp -fPIC -O2 -ffast-math -fomit-frame-pointer /Users/gsingh/Programming/garage/third-party/Healpix_3.11/src/cxx/osx/lib/libhealpix_cxx.a /Users/gsingh/Programming/garage/third-party/Healpix_3.11/src/cxx/osx/lib/libcxxsupport.a /Users/gsingh/Programming/garage/third-party/Healpix_3.11/src/cxx/osx/lib/libsharp.a /Users/gsingh/Programming/garage/third-party/Healpix_3.11/src/cxx/osx/lib/libfftpack.a /Users/gsingh/Programming/garage/third-party/Healpix_3.11/src/cxx/osx/lib/libc_utils.a -L / usr / local / opt / cfitsio / lib -lcfitsio