POCO로 응용 프로그램을 만들 때 컴파일 오류에 대해 이상한 점이 발견되었습니다.POCO와 공유 메모리를 사용할 때 링크 오류
나는 다른 사람의 비슷한 문제를 확인하여 -lrt를 추가했습니다. 그러나 여전히 작동하지 않습니다.
/usr/local/lib//libPocoFoundation.a(SharedMemory.o): In function
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' SharedMemory.cpp:(.text+0x31b): undefined reference toshm_unlink' /usr/local/lib//libPocoFoundation.a(SharedMemory.o): In function
Poco::SharedMemoryImpl::close()': SharedMemory.cpp:(.text+0x666): undefined reference to `shm_unlink' collect2: error: ld returned 1 exit status Makefile:17: recipe for target 'test' failed make: *** [test] Error 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;
}
성공적으로 만들어졌습니다.
&이 그런 이상한 해결 방법을 피하기 위해 공식을 검색하는 이유를 이해할 수 없습니다. 누구든지 도와 드릴 수 있습니까?
또한, 나는 libPocoFoundation.a을 확인하고
이
'기호는 정의되지 않는다'에 속하는 두
shm_open
shm_unlink을 찾을 수있다 미리 감사드립니다.
연결 오류가 있습니다. 우리는 당신을 도울 실패 linkage 명령을 참조해야합니다. 귀하의 질문 본문에 편집되지 않은 전체 빌드 로그를 게시하십시오. –