当前位置: 技术问答>linux和unix
Linux 编译链接问题
来源: 互联网 发布时间:2016-10-15
本文导语: macro.h:16:25: warning: backslash and newline separated by space macro.h:20:26: warning: backslash and newline separated by space macro.h:28:6: warning: backslash and newline separated by space /tmp/cc6nHVFA.o(.text+0xaf): In function `main': : undefined refe...
macro.h:16:25: warning: backslash and newline separated by space
macro.h:20:26: warning: backslash and newline separated by space
macro.h:28:6: warning: backslash and newline separated by space
/tmp/cc6nHVFA.o(.text+0xaf): In function `main':
: undefined reference to `TMainCtrl::instance()'
/tmp/cc6nHVFA.o(.text+0xd8): In function `main':
: undefined reference to `TMainCtrl::instance()'
/tmp/cc6nHVFA.o(.text+0xe1): In function `main':
: undefined reference to `TMainCtrl::init()'
/tmp/cc6nHVFA.o(.text+0x11c): In function `main':
: undefined reference to `TMainCtrl::instance()'
/tmp/cc6nHVFA.o(.text+0x125): In function `main':
: undefined reference to `TMainCtrl::mainLoop()'
collect2: ld returned 1 exit status
问题描述:
在A文件中实现了单例,在B文件中的main函数中调用。编译后在链接时报错?
请朋友们帮忙看看
macro.h:20:26: warning: backslash and newline separated by space
macro.h:28:6: warning: backslash and newline separated by space
/tmp/cc6nHVFA.o(.text+0xaf): In function `main':
: undefined reference to `TMainCtrl::instance()'
/tmp/cc6nHVFA.o(.text+0xd8): In function `main':
: undefined reference to `TMainCtrl::instance()'
/tmp/cc6nHVFA.o(.text+0xe1): In function `main':
: undefined reference to `TMainCtrl::init()'
/tmp/cc6nHVFA.o(.text+0x11c): In function `main':
: undefined reference to `TMainCtrl::instance()'
/tmp/cc6nHVFA.o(.text+0x125): In function `main':
: undefined reference to `TMainCtrl::mainLoop()'
collect2: ld returned 1 exit status
问题描述:
在A文件中实现了单例,在B文件中的main函数中调用。编译后在链接时报错?
请朋友们帮忙看看
#include "externinterface.h"
#include "const.h"
int main(int argc, char* argv[])
{
if (NULL == TMainCtrl::instance())
{
printf("Create cmanagerEntity is failed!n");
exit(1);
}
if (!TMainCtrl::instance()->init())
{
printf("initlialize TCmanager entity is error!n");
exit(1);
}
signal(SIGPIPE, SIG_IGN);
TMainCtrl::instance()->mainLoop();
return 0;
}
|
只有这个一个.o文件么?
/home/super/obj/cmanager/exIn_main.o
/home/super/obj/cmanager/exIn_main.o
|
你是怎么编译的?
|
TMainCtrl怎么写的?
|
instance的返回值是啥?
|
TMain在哪个头文件里, externinterface.h?
|