当我用POCO创建应用程序时,我发现编译错误很奇怪。
我根据检查其他人添加-lrt'类似的问题。但是,它仍然不起作用。
/usr/local/lib//libPocoFoundation.a(SharedMemory.o):在功能中
Poco::SharedMemoryImpl::SharedMemoryImpl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, Poco::SharedMemory::AccessMode, void const*, bool)': SharedMemory.cpp:(.text+0x2ab): undefined reference to
的shm_open&#39; SharedMemory.cpp :(。text + 0x31b):未定义引用shm_unlink' /usr/local/lib//libPocoFoundation.a(SharedMemory.o): In function
Poco :: SharedMemoryImpl :: close()&#39 ;: SharedMemory.cpp :(。text + 0x666): 未定义的引用`shm_unlink&#39; collect2:错误:ld返回1 退出状态Makefile:17:目标配方&#39; test&#39;失败了:*** [测试]错误1
奇怪的是,如果我添加一个虚拟函数,如下所示。
int dummy()
{
const char *memname = "sample";
const size_t region_size = sysconf(_SC_PAGE_SIZE);
int fd = shm_open(memname, O_CREAT | O_TRUNC | O_RDWR, 0666);
if (fd == -1)
return -1;
int r = shm_unlink(memname);
if (r != 0)
return -1;
}
它已成功构建。
我无法理解为什么&amp;想搜索正式以避免这种奇怪的解决方法。 请问有人可以提供帮助吗?
另外,我检查了libPocoFoundation.a并找到了两个
的shm_open
shm_unlink
属于&#39;符号未定义&#39;
提前致谢。