Poco错误

时间:2016-02-04 20:43:36

标签: c++ poco-libraries

我想在我的C ++项目中使用Poco库。 但是我在编译时遇到错误。

我正在开发Ubuntu OS,CLion 1.2.4 IDE

这是我的源代码:

#include "Poco/Net/ServerSocket.h"
#include <iostream>

int main(int arc, char** argv){
    std::cout << "Hello world!";
    return 0;
}

这是我的CMakeLists.txt文件:

cmake_minimum_required(VERSION 3.3)
project(rcp)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")

include_directories("libraries")

add_executable(rcp ${SOURCE_FILES})

target_link_libraries(rcp pthread PocoNet PocoUtil PocoFoundation)

这是我编译时的输出:

CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv6SocketAddressImpl::host() const':
main.cpp:(.text._ZNK4Poco3Net4Impl21IPv6SocketAddressImpl4hostEv[_ZNK4Poco3Net4Impl21IPv6SocketAddressImpl4hostEv]+0x11): undefined reference to `Poco::Net::IPAddress::IPAddress(void const*, unsigned int, unsigned int)'
CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv6SocketAddressImpl::~IPv6SocketAddressImpl()':
main.cpp:(.text._ZN4Poco3Net4Impl21IPv6SocketAddressImplD2Ev[_ZN4Poco3Net4Impl21IPv6SocketAddressImplD5Ev]+0x8): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv6SocketAddressImpl::~IPv6SocketAddressImpl()':
main.cpp:(.text._ZN4Poco3Net4Impl21IPv6SocketAddressImplD0Ev[_ZN4Poco3Net4Impl21IPv6SocketAddressImplD5Ev]+0xc): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv4SocketAddressImpl::~IPv4SocketAddressImpl()':
main.cpp:(.text._ZN4Poco3Net4Impl21IPv4SocketAddressImplD2Ev[_ZN4Poco3Net4Impl21IPv4SocketAddressImplD5Ev]+0x8): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
CMakeFiles/rcp.dir/main.cpp.o: In function `Poco::Net::Impl::IPv4SocketAddressImpl::~IPv4SocketAddressImpl()':
main.cpp:(.text._ZN4Poco3Net4Impl21IPv4SocketAddressImplD0Ev[_ZN4Poco3Net4Impl21IPv4SocketAddressImplD5Ev]+0xc): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
CMakeFiles/rcp.dir/main.cpp.o:(.rodata._ZTIN4Poco3Net4Impl21IPv4SocketAddressImplE[_ZTIN4Poco3Net4Impl21IPv4SocketAddressImplE]+0x10): undefined reference to `typeinfo for Poco::Net::Impl::SocketAddressImpl'
CMakeFiles/rcp.dir/main.cpp.o:(.rodata._ZTIN4Poco3Net4Impl21IPv6SocketAddressImplE[_ZTIN4Poco3Net4Impl21IPv6SocketAddressImplE]+0x10): undefined reference to `typeinfo for Poco::Net::Impl::SocketAddressImpl'
collect2: error: ld returned 1 exit status
CMakeFiles/rcp.dir/build.make:94: recipe for target '/home/john/projects/rightChoiceProperty/bin/rcp' failed
make[3]: *** [/home/john/projects/rightChoiceProperty/bin/rcp] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/rcp.dir/all' failed
make[2]: *** [CMakeFiles/rcp.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/rcp.dir/rule' failed
make[1]: *** [CMakeFiles/rcp.dir/rule] Error 2
Makefile:118: recipe for target 'rcp' failed
make: *** [rcp] Error 2

我的问题在哪里我今天都搜索了但我找不到任何东西请帮助我解决这个问题。

谢谢大家

1 个答案:

答案 0 :(得分:0)

我解决了这个问题,因为&#34; M.M&#34;以上评论指南:

  

输出表明你实际上没有链接到Poco :: Net。   另一种可能性是,如果您正在使用Poco标头   不同版本的Poco比你正在链接的编译库   对

我删除了更改include以包含右侧库。

起初这是我的包含行:

#include "Poco/Net/ServerSocket.h"

已更改为

#include <Poco/Net/ServerSocket.h>

现在一切正常。

谢谢M.M