Visual C++ 2015 中的 CSpice:Link 个错误
CSpice in Visual C++ 2015: Link errors
我正在尝试使用 Nasa 的 CSpice 工具包,但是当我尝试构建我的代码时,我收到类似
的错误
LNK2028 unresolved token (0A0004E6) "extern "C" void __cdecl spkpos_c(char const *,double,char const *,char const *,char const *,double * const,double *)"
我已经将库 (cspice.lib) 放入链接器中
Project Property page 并导入了 headers.
关于问题可能是什么的任何想法?
代码:
#include <iostream>
#include "stdafx.h"
#include "Calculation.h"
#include <ctime>
#include <string>
#include <sstream>
SpiceDouble* Calculation::sunPosition()
{
//--Kernels--
//Load Earth data
furnsh_c("..\data\earth_pck\earth_latest_high_precision.bpc");
//Load LeapSeconds tabulation for time convertion
furnsh_c("..\data\all_spk\naif0011.tls.pc");
//Framework used is J2000, so it does not need to be loaded
//--Variables--
SpiceDouble epochTime;
SpiceDouble sunPosition[3];
SpiceDouble lightYears;
//--Calculation--
//Seconds past J2000 TDB
time_t t = time(0);
struct tm* utcNow = gmtime(&t);
std::string month;
switch (utcNow->tm_mon)
{
case 0:
month = "JAN";
break;
case 1:
month = "FEB";
break;
case 2:
month = "MAR";
break;
case 3:
month = "APR";
break;
case 4:
month = "MAY";
break;
case 5:
month = "JUN";
break;
case 6:
month = "JUL";
break;
case 7:
month = "AUG";
break;
case 8:
month = "SEP";
break;
case 9:
month = "OCT";
break;
case 10:
month = "NOV";
break;
case 11:
month = "DEC";
break;
}
std::stringstream format;
format << (utcNow->tm_year + 1900) << " ";
format << month << " " << utcNow->tm_mday << " ";
format << utcNow->tm_hour << ":";
format << utcNow->tm_min << ":";
format << utcNow->tm_sec;
ConstSpiceChar* et = format.str().c_str();
str2et_c(et, &epochTime);
//Get current sun position relative to earth, using earth as the inertia center
spkpos_c("sun", epochTime, "iau_earth", "none", "earth", sunPosition, &lightYears);
printf("%f", sunPosition);
return sunPosition;
}
解决了。
解决方案:库是 x64,Visual C++ 配置为 x86。
-> 运行 "vcvarsall.bat amd64" 在 cmd 中并将项目更改为构建 x64
我正在尝试使用 Nasa 的 CSpice 工具包,但是当我尝试构建我的代码时,我收到类似
的错误LNK2028 unresolved token (0A0004E6) "extern "C" void __cdecl spkpos_c(char const *,double,char const *,char const *,char const *,double * const,double *)"
我已经将库 (cspice.lib) 放入链接器中
Project Property page 并导入了 headers.
关于问题可能是什么的任何想法?
代码:
#include <iostream>
#include "stdafx.h"
#include "Calculation.h"
#include <ctime>
#include <string>
#include <sstream>
SpiceDouble* Calculation::sunPosition()
{
//--Kernels--
//Load Earth data
furnsh_c("..\data\earth_pck\earth_latest_high_precision.bpc");
//Load LeapSeconds tabulation for time convertion
furnsh_c("..\data\all_spk\naif0011.tls.pc");
//Framework used is J2000, so it does not need to be loaded
//--Variables--
SpiceDouble epochTime;
SpiceDouble sunPosition[3];
SpiceDouble lightYears;
//--Calculation--
//Seconds past J2000 TDB
time_t t = time(0);
struct tm* utcNow = gmtime(&t);
std::string month;
switch (utcNow->tm_mon)
{
case 0:
month = "JAN";
break;
case 1:
month = "FEB";
break;
case 2:
month = "MAR";
break;
case 3:
month = "APR";
break;
case 4:
month = "MAY";
break;
case 5:
month = "JUN";
break;
case 6:
month = "JUL";
break;
case 7:
month = "AUG";
break;
case 8:
month = "SEP";
break;
case 9:
month = "OCT";
break;
case 10:
month = "NOV";
break;
case 11:
month = "DEC";
break;
}
std::stringstream format;
format << (utcNow->tm_year + 1900) << " ";
format << month << " " << utcNow->tm_mday << " ";
format << utcNow->tm_hour << ":";
format << utcNow->tm_min << ":";
format << utcNow->tm_sec;
ConstSpiceChar* et = format.str().c_str();
str2et_c(et, &epochTime);
//Get current sun position relative to earth, using earth as the inertia center
spkpos_c("sun", epochTime, "iau_earth", "none", "earth", sunPosition, &lightYears);
printf("%f", sunPosition);
return sunPosition;
}
解决了。
解决方案:库是 x64,Visual C++ 配置为 x86。 -> 运行 "vcvarsall.bat amd64" 在 cmd 中并将项目更改为构建 x64