poco mysql 编译_Ubuntu 16.04上源码编译Poco并编写cmake文件

guide to compile and install poco cpp library on ubuntu 16.04

Series

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

History

20180222: created.

Copyright

Post author: kezunlin

Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在非root用户下安装OpenCV4并使用g++/CMake编译,可以按照以下步骤进行操作: 1. 安装必要的依赖项 ``` sudo apt-get update sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev ``` 2. 下载OpenCV4源代码 ``` git clone https://github.com/opencv/opencv.git cd opencv git checkout 4.0.0 ``` 3. 创建一个build目录并进行编译 ``` mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=$HOME/opencv_install -DCMAKE_BUILD_TYPE=Release .. make -j8 make install ``` 其中,`$HOME/opencv_install` 是你想要安装OpenCV4的路径。 4. 配置环境变量 将以下内容添加到你的`.bashrc`文件中: ``` export PKG_CONFIG_PATH=$HOME/opencv_install/lib/pkgconfig:$PKG_CONFIG_PATH export LD_LIBRARY_PATH=$HOME/opencv_install/lib:$LD_LIBRARY_PATH ``` 然后执行以下命令使其生效: ``` source ~/.bashrc ``` 5. 编写CMakeLists.txt并进行编译 在你的项目目录中创建一个 `CMakeLists.txt` 文件,并在其中添加以下内容: ``` cmake_minimum_required(VERSION 2.8) project(your_project_name) find_package(OpenCV REQUIRED) add_executable(your_executable_name your_source_files.cpp) target_link_libraries(your_executable_name ${OpenCV_LIBS}) ``` 将 `your_project_name` 和 `your_executable_name` 分别替换为你的项目名和可执行文件名。 然后在项目目录下创建一个 `build` 目录,并在其中进行编译: ``` mkdir build cd build cmake .. make ``` 编译完成后,你的可执行文件将位于 `build` 目录下。 以上就是在非root用户下安装OpenCV4并使用g++/CMake编译的步骤。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值