GCC在链接程序时,报"undefined reference to .."错误
在Common.h下
有2个函数为
SWORDFISH_DLL_SPEC time_t SwordFishTime();
SWORDFISH_DLL_SPEC uint32 SwordFishMilliTime();
SWORDFISH_DLL_SPEC的定义在另外一个.h文件
#if PLATFORM == PLATFORM_WINDOWS
# define SWORDFISH_DLL_SPEC __declspec(dllexport)
# ifndef DECLSPEC_NORETURN
# define DECLSPEC_NORETURN __declspec(noreturn)
# endif //DECLSPEC_NORETURN
#else //PLATFORM != PLATFORM_WINDOWS
# define SWORDFISH_DLL_SPEC
# define DECLSPEC_NORETURN
#endif //PLATFORM
swordFishTime和SwordFishMilliTime的实体函数在一个CPP文件中。
inline time_t SwordFishTime()
{
return sWorld.GetGameTime();//sWorld为单键模式的一个实体
}
inline uint32 SwordFishMilliTime()
{
return sWorld.GetMillGameTime();
}
这两个函数在很多地方被调用。一共13个项目,在G++下都编译通过。但是在链接可执行文件时,
编译器报错:undefine reference
obj/Debug/src/swordfishd/WorldRunnable.o: In function `WorldRunnable::run()':
undefined reference to `SwordFishMilliTime()'
undefined reference to `SwordFishMilliTime()'
/usr/local/mmo/Server/trunk/src/swordfishd/WorldRunnable.cpp:93: undefined reference to `SwordFishMilliTime()'
obj/Debug/src/swordfishd/WorldRunnable.o:/usr/local/mmo/Server/trunk/src/swordfishd/WorldRunnable.cpp:100: more undefined references to `SwordFishMilliTime()' follow
请问是为什么啊?如何让其链接成功呢?