C语言构建错误,如何在构建C程序时解决CodeBlocks中的'Multiple Definitions of'错误?...

我正在尝试在CodeBlocks中构建此项目,以便可以逐步执行其中一个功能,但我在构建它时遇到了问题。这是我的错误如何在构建C程序时解决CodeBlocks中的'Multiple Definitions of'错误?

||=== Build: Debug in MAGLAT (compiler: GNU GCC Compiler) ===|

obj\Debug\GMCORD.o||In function `GM_CartesianToSpherical':|

C:\Users\Guest\SkyDrive\temp\MAGLAT\MAGLAT\GM_SubLibrary.c|11|multiple definition of `GM_CartesianToSpherical'|

obj\Debug\GM_SubLibrary.o:C:\Users\Guest\SkyDrive\temp\MAGLAT\MAGLAT\GM_SubLibrary.c|11|first defined here|

//头文件

#ifndef GMHEADER_H

#define GMHEADER_H

#endif

#ifndef M_PI

#define M_PI ((2)*(acos(0.0)))

#endif

#define GM_STARTYEAR 1900

#define RAD2DEG(rad) ((rad)*(180.0L/M_PI))

#define DEG2RAD(deg) ((deg)*(M_PI/180.0L))

#define ATanH(x) (0.5 * log((1 + x)/(1 - x)))

#define MU_0 4*M_PI/10000000

#define R_e 6.371 * 1000000

#define TRUE ((int)1)

#define FALSE ((int)0)

typedef struct {

int Day;

int Month;

int Year;

double DecimalYear;

int DayNumber;

} GMtype_Date;

typedef struct {

double lambda;// longitude

double phi; // geodetic latitude

double HeightAboveEllipsoid; // height above the ellipsoid (HaE)

} GMtype_CoordGeodetic;

typedef struct {

...

...

}...;

//GM Cord functions

void GM_CartesianToSpherical(GMtype_CoordCartesian CoordCartesian, GMtype_CoordSpherical *CoordSpherical);

///GM_SubLibrary.c

#include

#include

#include

#include

#include "GMHeader.h"

void GM_CartesianToSpherical(GMtype_CoordCartesian CoordCartesian, GMtype_CoordSpherical *CoordSpherical)

{

/*This function converts a point from Cartesian coordinates into spherical coordinates*/

double X, Y, Z;

X = CoordCartesian.x;

Y = CoordCartesian.y;

Z = CoordCartesian.z;

CoordSpherical->r = sqrt(X * X + Y * Y + Z * Z);

CoordSpherical->phig = RAD2DEG(asin(Z/(CoordSpherical->r)));

CoordSpherical->lambda = RAD2DEG(atan2(Y, X));

} /*GM_CartesianToSpherical*/

///GMCORD.c

//----------------------------------------------------------------------------------------

#include

#include

#include

#include

#include "GM_SubLibrary.c"

//----------------------------------------------------------------------------------------

int main()

{

int Flag = 1;

char ans[20];

GMtype_Date date;

GMtype_Data G0, G1, H1;

GMtype_CoordGeodetic location;

GMtype_CoordDipole GMlocation;

GMtype_Ellipsoid Ellip;

GM_ScanIGRF(&G0, &G1, &H1);

GM_SetEllipsoid(&Ellip);

while(Flag == 1) {

GM_GetUserInput(&location, &date);

GM_CORD(location, &date, Ellip, G0, G1, H1, &GMlocation);

GM_PrintUserData(location, date, GMlocation);

...

}

return 1;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值