- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是 C++ 新手。最终,我试图从 python 中翻译一些代码,以便对一些超新星模拟进行分析。但是,为了做到这一点,我必须能够将 .fits 文件作为数组导入到我的 C++ 代码中。我下载了 cfitsio 和 ccfits 库,考虑到由 #include <CCfits>
组成的简单代码,它们似乎已正确安装。一个带有 print 语句的 int main 编译并运行。但是,从 NASA ( http://heasarc.gsfc.nasa.gov/fitsio/CCfits/html/readimage.html ) 获取演示代码并将名称更改为我希望打开的 .fits 文件(位于我的主目录中)以使用这些库导入 .fits 文件不会编译。我使用的精确代码 (Sobelattempt.cc) 是:
#include <CCfits>
#include <iostream>
#include <cmath>
#include <memory>
using namespace CCfits;
int readimage()
{
std::auto_ptr<FITS> pInfile(new FITS("Supernova45F.fits",Read,true));
PHDU& image=pInfile->pHDU();
std::valarray<unsigned long> contents;
// read all user-specifed, coordinate, and checksum keys in the image
image.readAllKeys();
image.read(contents);
// this doesn't print the data, just header info.
std::cout << image << std::endl;
long ax1(image.axis(0));
long ax2(image.axis(1));
for (long j = 0; j < ax2; j+=10)
{
std::ostream_iterator<short> c(std::cout,"\t");
std::copy(&contents[j*ax1],&contents[(j+1)*ax1-1],c);
std::cout << '\n';
}
std::cout << std::endl;
return 0;
}
int main(){
return 0;
}
我正在使用命令进行编译:
g++ Sobelattempt.cc -o Sobel -I/home/Sam/CCfits -I/home/Sam/cfitsio
我得到了错误:
/tmp/ccS0m6h4.o: In function `readimage()':
Sobelattempt.cc:(.text+0x69): undefined reference to `CCfits::FITS::FITS(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, CCfits::RWmode, bool, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)'
Sobelattempt.cc:(.text+0x15e): undefined reference to `CCfits::FITS::pHDU()'
Sobelattempt.cc:(.text+0x17d): undefined reference to `CCfits::HDU::readAllKeys()'
/tmp/ccS0m6h4.o: In function `std::auto_ptr<CCfits::FITS>::~auto_ptr()':
Sobelattempt.cc:(.text._ZNSt8auto_ptrIN6CCfits4FITSEED2Ev[_ZNSt8auto_ptrIN6CCfits4FITSEED5Ev]+0x1d): undefined reference to `CCfits::FITS::~FITS()'
/tmp/ccS0m6h4.o: In function `void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)':
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x73): undefined reference to `typeinfo for CCfits::PHDU'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x12f): undefined reference to `typeinfo for CCfits::PHDU'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x20d): undefined reference to `typeinfo for CCfits::PHDU'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x2ec): undefined reference to `typeinfo for CCfits::PHDU'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x3b5): undefined reference to `CCfits::ULBASE'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x435): undefined reference to `typeinfo for CCfits::PHDU'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x4d1): undefined reference to `typeinfo for CCfits::PHDU'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x59d): undefined reference to `CCfits::USBASE'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x61d): undefined reference to `typeinfo for CCfits::PHDU'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x6b9): undefined reference to `typeinfo for CCfits::PHDU'
Sobelattempt.cc:(.text._ZN6CCfits4PHDU4readImEEvRSt8valarrayIT_EllPS3_[void CCfits::PHDU::read<unsigned long>(std::valarray<unsigned long>&, long, long, unsigned long*)]+0x77f): undefined reference to `CCfits::FitsFatal::FitsFatal(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccS0m6h4.o:(.rodata._ZTIN6CCfits10PrimaryHDUImEE[typeinfo for CCfits::PrimaryHDU<unsigned long>]+0x10): undefined reference to `typeinfo for CCfits::PHDU'
/tmp/ccS0m6h4.o:(.rodata._ZTIN6CCfits10PrimaryHDUIsEE[typeinfo for CCfits::PrimaryHDU<short>]+0x10): undefined reference to `typeinfo for CCfits::PHDU'
/tmp/ccS0m6h4.o:(.rodata._ZTIN6CCfits10PrimaryHDUItEE[typeinfo for CCfits::PrimaryHDU<unsigned short>]+0x10): undefined reference to `typeinfo for CCfits::PHDU'
/tmp/ccS0m6h4.o:(.rodata._ZTIN6CCfits10PrimaryHDUIiEE[typeinfo for CCfits::PrimaryHDU<int>]+0x10): undefined reference to `typeinfo for CCfits::PHDU'
/tmp/ccS0m6h4.o:(.rodata._ZTIN6CCfits10PrimaryHDUIjEE[typeinfo for CCfits::PrimaryHDU<unsigned int>]+0x10): undefined reference to `typeinfo for CCfits::PHDU'
/tmp/ccS0m6h4.o:(.rodata._ZTIN6CCfits10PrimaryHDUIhEE[typeinfo for CCfits::PrimaryHDU<unsigned char>]+0x10): more undefined references to `typeinfo for CCfits::PHDU' follow
collect2: ld returned 1 exit status
最佳答案
链接到 CCfits 库的两个链接器选项是 -lCCfits -lcfitsio。此外, -L... 标志如果 LD_LIBRARY_PATH 没有覆盖这两个库的目录,则可能需要。
关于c++ - CCfits 库演示代码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17829788/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!