这可能与
从来没有回答。
无论如何,我希望我的问题更容易重现。CCfits 的示例程序位于:
http://heasarc.gsfc.nasa.gov/fitsio/CCfits/html/cookbook.html
我正在尝试使用以下方法编译它:
g++ cookbook.cpp -o cookbook -lCCfits -lcfitsio
文件中每个 CCfits 函数的链接都失败:
/tmp/cc7hVaju.o: 在函数
main': cookbook.cpp:(.text+0x14): undefined reference to
writeImage()'cookbook.cpp:(.text+0x31): undefined reference towriteAscii()' cookbook.cpp:(.text+0x4e): undefined reference to
writeBinary()' cookbook.cpp:(.text+0x6b): undefined reference tocopyHDU()' cookbook.cpp:(.text+0x88): undefined reference to
readHeader()' cookbook .cpp:(.text+0xa5): 未定义对readImage()' cookbook.cpp:(.text+0xc2): undefined reference to
readTable()' 的引用 cookbook.cpp:(.text+0xdf): 未定义对readExtendedSyntax()' cookbook.cpp:(.text+0xfc): undefined reference to
selectRows()'collect2 的引用:错误:ld 返回 1 个退出状态
我已经用 Ubuntu 自带的 CCfits 包试过了。我也尝试过自己安装包。同样的错误。
奇怪的是,如果我不在命令行中包含库(即“g++ cookbook.cpp -o cookbook”),我会收到类似的消息。一个区别是我也收到此错误:
/tmp/ccMVMkSB.o: 在函数
CCfits::FITS::setVerboseMode(bool)': cookbook.cpp:(.text._ZN6CCfits4FITS14setVerboseModeEb[_ZN6CCfits4FITS14setVerboseModeEb]+0xf): undefined reference to
CCfits::FITS::s_verboseMode'
这应该是个线索吧?似乎是说我命名的库虽然存在,但并不包含我需要的所有功能。
谢谢你的帮助,
查尔斯