0

我想使用AA+ 天文类框架,我只想让示例应用程序运行(它包含在框架 zip 文件AATest.cpp

我打开 Xcode,为 C++ 应用程序创建了一个新项目,然后将AA+.hstdafx.h文件添加到项目中,因为它们包含在内。然后,当我构建项目时,我收到很多链接器错误,因为它似乎无法找到与某些示例应用程序代码关联的符号。

我尝试在 Xcode 的 Build 设置中将路径AA+.hstdafx.h文件添加到库和标头搜索路径,但这并没有改变任何东西,错误仍然存​​在。

我究竟做错了什么?这是我第一次在 Xcode 中使用 C++。我是否必须首先将 AA+ 框架构建为静态库,或者我可以以这种方式包含它吗?

通过 Xcode 编译:

Ld /Users/me/Library/Developer/Xcode/DerivedData/AAPlus-bzgonjwgqlpgescueekcoobljdyf/Build/Products/Debug/AAPlus normal x86_64
    cd "/Users/me/Downloads/aaplus astronomy c++/Example/AAPlus"
    setenv MACOSX_DEPLOYMENT_TARGET 10.7
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/me/Library/Developer/Xcode/DerivedData/AAPlus-bzgonjwgqlpgescueekcoobljdyf/Build/Products/Debug -F/Users/me/Library/Developer/Xcode/DerivedData/AAPlus-bzgonjwgqlpgescueekcoobljdyf/Build/Products/Debug -filelist /Users/me/Library/Developer/Xcode/DerivedData/AAPlus-bzgonjwgqlpgescueekcoobljdyf/Build/Intermediates/AAPlus.build/Debug/AAPlus.build/Objects-normal/x86_64/AAPlus.LinkFileList -mmacosx-version-min=10.7 -stdlib=libc++ -o /Users/me/Library/Developer/Xcode/DerivedData/AAPlus-bzgonjwgqlpgescueekcoobljdyf/Build/Products/Debug/AAPlus

错误:

Undefined symbols for architecture x86_64:
  "CAANutation::TrueObliquityOfEcliptic(double)", referenced from:
      GetSolarRaDecByJulian(double, double&, double&) in main.o
      GetLunarRaDecByJulian(double, double&, double&) in main.o
  "CAADynamicalTime::DeltaT(double)", referenced from:
      GetSolarRaDecByJulian(double, double&, double&) in main.o
  "CAARiseTransitSet::Calculate(double, double, double, double, double, double, double, double, double, double)", referenced from:
      GetSunRiseTransitSet(double, double, double) in main.o
      GetMoonRiseTransitSet(double, double, double) in main.o
  "CAAMoonIlluminatedFraction::PhaseAngle(double, double, double)", referenced from:
      GetMoonIllumination(double, double&, double&, double&) in main.o
  "CAAMoonIlluminatedFraction::PositionAngle(double, double, double, double)", referenced from:
      GetMoonIllumination(double, double&, double&, double&) in main.o
  "CAAMoonIlluminatedFraction::IlluminatedFraction(double)", referenced from:
      GetMoonIllumination(double, double&, double&, double&) in main.o
  "CAAMoonIlluminatedFraction::GeocentricElongation(double, double, double, double)", referenced from:
      GetMoonIllumination(double, double&, double&, double&) in main.o
  "CAACoordinateTransformation::Ecliptic2Equatorial(double, double, double)", referenced from:
      GetSolarRaDecByJulian(double, double&, double&) in main.o
      GetLunarRaDecByJulian(double, double&, double&) in main.o
  "CAASun::ApparentEclipticLatitude(double)", referenced from:
      GetSolarRaDecByJulian(double, double&, double&) in main.o
  "CAASun::ApparentEclipticLongitude(double)", referenced from:
      GetSolarRaDecByJulian(double, double&, double&) in main.o
  "CAADate::CAADate(double, bool)", referenced from:
      PrintTime(double, char const*) in main.o
  "CAADate::CAADate(long, long, double, bool)", referenced from:
      PrintSunAndMoonInfo(int, int, int, double, double) in main.o
  "CAAMoon::EclipticLatitude(double)", referenced from:
      GetLunarRaDecByJulian(double, double&, double&) in main.o
  "CAAMoon::EclipticLongitude(double)", referenced from:
      GetLunarRaDecByJulian(double, double&, double&) in main.o
  "CAADate::Get(long&, long&, long&, long&, long&, double&) const", referenced from:
      PrintTime(double, char const*) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
4

1 回答 1

1

代码

您可以在 XCode 中执行以下操作:

  1. 创建一个新项目AATest
  2. aaplus/包含框架代码的文件夹复制到项目文件夹中
  3. 在您的 XCode 项目中,按住control并单击Source
  4. 选择添加 > 现有文件...
  5. 选择aaplus/文件夹并将其添加到您的项目中
  6. 建造。

可执行文件将在build/Debug/AATest.

选择

由于项目包含一个文件CMakeLists.txt,您可以使用cmake. 在您的框架文件夹中,在终端上运行以下命令:

mkdir build/
cd build/
cmake ..
make
于 2012-10-02T20:14:49.953 回答