首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

undefined reference解决方法

2012-02-19 
undefined reference编译时出错:.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_exec.o /e

undefined reference
编译时出错:
.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_exec.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_ord2utf8.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_newline.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_fullinfo.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_xclass.o -L/e/pocobuild/lib/MinGW/ia32 -liphlpapi -lws2_32 -lpcre
Creating library file: e:/pocobuild/lib/MinGW/ia32/libPocoFoundationd.a
e:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/LoggingFactory.o(.text$_ZNK4Poco12InstantiatorINS_15EventLogChannelENS_7ChannelEE14createInstanceEv[Poco::Instantiator<Poco::EventLogChannel, Poco::Channel>::createInstance() const]+0x59): In function `ZN4Poco12InstantiatorINS_17FormattingChannelENS_7ChannelEED1Ev':
e:/poco-1.3.1-data/Foundation/include/Poco/Instantiator.h: undefined reference to `Poco::EventLogChannel::EventLogChannel()'
e:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/LoggingFactory.o(.text$_ZNK4Poco12InstantiatorINS_21WindowsConsoleChannelENS_7ChannelEE14createInstanceEv[Poco::Instantiator<Poco::WindowsConsoleChannel, Poco::Channel>::createInstance() const]+0x59):e:/poco-1.3.1-data/Foundation/include/Poco/Instantiator.h: undefined reference to `Poco::WindowsConsoleChannel::WindowsConsoleChannel()'
e:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/SyslogChannel.o(.text+0x6e4): In function `ZN4Poco13SyslogChannel4openEv':
e:/poco-1.3.1-data/Foundation/src/SyslogChannel.cpp:76: undefined reference to `openlog'
e:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/SyslogChannel.o(.text+0x702): In function `ZN4Poco13SyslogChannel5closeEv':
e:/poco-1.3.1-data/Foundation/src/SyslogChannel.cpp:85: undefined reference to `closelog'
e:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/SyslogChannel.o(.text+0x762): In function `ZN4Poco13SyslogChannel3logERKNS_7MessageE':
e:/poco-1.3.1-data/Foundation/src/SyslogChannel.cpp:94: undefined reference to `syslog'

看样子是是缺少可查了很久
第一我包含了<syslog.h>//这个只有openlog(),closelog()的声明,缺没有定义,
我不知道到底怎么回事?是不是g++时 没有带什么时候-l参数如果缺少库是缺那个我也不知道,望高手指点


[解决办法]
syslog应该属于glibc中API.
尝试一下在e:/pocobuild/lib/MinGW/ia32/libPocoFoundationd.a 
的makefile中加入glibc
[解决办法]
syslog is a system call in linux/unix system, mingw possibly don't supply it. You can just redefined those function, remapping them to whatever you want.
[解决办法]
应该是makefile中,objs没有加入相应模块,连接的时候出问题了。

热点排行