相关文章推荐
卖萌的烤地瓜  ·  jquery ...·  8 月前    · 
豁达的针织衫  ·  TP5 ...·  1 年前    · 
Ubuntu 16.04上源码编译Poco并编写cmake文件 | guide to compile and install poco cpp library on ubuntu 16.04 helloai92567 2019年11月12日 11:04 ·  阅读

本文首发于个人博客 kezunlin.me/post/281dd8… ,欢迎阅读!

guide to compile and install poco cpp library on ubuntu 16.04

Series

  • guide to compile and install poco cpp library on windows
  • guide to compile and install poco cpp library on ubuntu 16.04

    Guide

    apt-get

    install by apt-get, but we can not use find_package(Poco) because no /usr/local/lib/cmake/Poco/PocoConfig.cmake installed.

        sudo apt-get install libpoco-doc libpoco-dev复制代码

    compile from source

        wget https://pocoproject.org/releases/poco-1.8.1/poco-1.8.1.tar.gz复制代码
        #Install dependences
        sudo apt-get install openssl libssl-dev
        sudo apt-get install libiodbc2 libiodbc2-dev
        sudo apt-get install libmysqlclient-dev复制代码
        cd poco-1.8.1
        #sudo ./configure --omit=Data/ODBC,Data/MySQL --no-tests --no-samples --shared
        cd build 
        cmake-gui ..
        sudo make -j8 
        sudo make install 复制代码

    OK. we install headers to /usr/local/include/Poco and libraries to /usr/local/lib/

        $ ls /usr/local/libPoco*.so 复制代码
        /usr/local/lib/libPocoFoundation.so  /usr/local/lib/libPocoNet.so   /usr/local/lib/libPocoXML.so
        /usr/local/lib/libPocoJSON.so        /usr/local/lib/libPocoUtil.so
    

    we install cmake files to /usr/local/lib/cmake/Poco

        $ ls /usr/local/lib/cmake/Poco复制代码
        PocoConfig.cmake                     PocoJSONTargets.cmake          PocoUtilTargets.cmake
        PocoConfigVersion.cmake              PocoJSONTargets-release.cmake  PocoUtilTargets-release.cmake
        PocoFoundationConfig.cmake           PocoNetConfig.cmake            PocoXMLConfig.cmake
        PocoFoundationConfigVersion.cmake    PocoNetConfigVersion.cmake     PocoXMLConfigVersion.cmake
        PocoFoundationTargets.cmake          PocoNetTargets.cmake           PocoXMLTargets.cmake
        PocoFoundationTargets-release.cmake  PocoNetTargets-release.cmake   PocoXMLTargets-release.cmake
        PocoJSONConfig.cmake                 PocoUtilConfig.cmake
        PocoJSONConfigVersion.cmake          PocoUtilConfigVersion.cmake复制代码

    Example

    CMakeLists.txt

    cmake_minimum_required (VERSION 2.6)
    project (event_demo)
    enable_language(C)
    enable_language(CXX)
    # Always include the source and build directories in the include path.
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    # Set the output folder where your program will be created
    set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
    set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
    set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
    # Find Poco package  1.8.1
    find_package(Poco REQUIRED COMPONENTS Foundation Util Net XML JSON)
    # no Poco_INCLUDE_DIRS, we have to set by hand 
    if(MSVC) # WIN32
        SET(Poco_INCLUDE_DIRS "C:/Program Files/Poco/include")
    else()
        SET(Poco_INCLUDE_DIRS "/usr/local/include/Poco")
    endif(MSVC)
    MESSAGE( [Main] " Poco_INCLUDE_DIRS = ${Poco_INCLUDE_DIRS}")
    MESSAGE( [Main] " Poco_LIBRARIES = ${Poco_LIBRARIES}")
    # The following folder will be included
    include_directories(
        ${MY_SRC_INCLUDE}  
        ${Poco_INCLUDE_DIRS} 
    link_directories(${CMAKE_BINARY_DIR}) 
    add_executable(event_demo event_demo.cpp)
    target_link_libraries(event_demo ${Poco_LIBRARIES})复制代码

    Reference

  • compile poco on ubuntu
  • install and compile poco on ubuntu
  • find poco
  • FindPoco.cmake
  • cmake-cannot-find-custom-module
  • poco cmake

    History

  • 20180222: created.
  • Post author: kezunlin
  • Post link: kezunlin.me/post/281dd8…
  • 分类:
    代码人生
  •