简体   繁体   中英

Linker errors for C++ framework test app

I would like to use the AA+ astronomy class framework and I just want to get the sample app running (it's included in the framework zip file as AATest.cpp )

I opened Xcode, created a new project for a C++ app, and then added the AA+.h and stdafx.h files to the project since they are includes. Then when I build the project, I get a lot of linker errors since it doesn't seem to be able to find the symbols associated with some of the sample app code.

I've tried adding the path to the AA+.h and stdafx.h files to the library and header search paths within the Build settings in Xcode, but that didn't change anything and the errors are still there.

What am I doing wrong? This is my first time working with C++ within Xcode. Do I have to build the AA+ framework as a static library first or can I just include it this way?

Compilation via 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

Errors:

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)

XCode

You can do the following in XCode:

  1. Create a new project AATest
  2. Copy your aaplus/ folder with the framework code into your project folder
  3. In your XCode project, hold control and click over Source
  4. Select Add > Existing Files...
  5. Select aaplus/ folder and Add it to your project
  6. Build.

The executable will be in build/Debug/AATest .

Alternative

As the project includes a file CMakeLists.txt , you can build your program using cmake . Inside your framework folder, run the following commands on your terminal:

mkdir build/
cd build/
cmake ..
make

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM