Poco学习

安装

  • 1.简单安装。
    简单安装直接使用 ubuntu 的软件仓库的就可以了。centos 下同样的。yum 安装即可。
sudo apt-get install libpoco-doc libpoco-dev
  • 2.完整安装(支持数据库)
    介绍:想要使用数据库及一些加密功能必须安装完整版的 poco .
    官网上已经有介绍了,完整安装需要外部依赖几个库,并且需要编译安装。
    .2)安装依赖(centos 下yum install openssl-devel …. 来满足依赖)
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install unixodbc
sudo apt-get install unixodbc-dev
sudo apt-get install libmysqlclient*

Foundation 库

SharedLibrary 模块

SharedLibrary 的功能一句话可以概括,在运行时动态的加载库和库内的类。也就是
说 SharedLibrary 提供了一个架构或者是约定,供库使用方和库提供方使用。只要满足了模
块约定,就可以快速实现调用。
对于库的调用来说,导出函数和导出类是基本的功能,windows 和 Linux 下具是如
此,因此 SharedLibrary 也必须实现此功能

在这里插入图片描述

导出函数

  • 代码结构
    在这里插入图片描述
  • src/test_poco.cpp
#include <Poco/SharedLibrary.h>

#include <iostream>

using Poco::SharedLibrary;
typedef void (*HelloFunc)();  // function pointer type
int main(int argc, char** argv) {
  std::string path("/mnt/d/ubuntu_workplace/poco_l/lib/libTestLibrary");
  path.append(SharedLibrary::suffix());  // adds ".dll" or ".so"
  std::cout << SharedLibrary::suffix() << std::endl;
  SharedLibrary library(path);  // will also load the library
  HelloFunc func = (HelloFunc)library.getSymbol("hello");
  func();
  library.unload();
  return 0;
}
  • src/CMakeLists.txt
include_directories(
    ./
    ${Poco_INCLUDE_DIRS}
)

message(${Poco_INCLUDE_DIRS})
add_executable(test_poco test_poco.cpp)

target_link_libraries(test_poco 
    ${Poco_LIBRARIES}
)
  • lib/testlib.cpp
#include <iostream>
#define LIBRARY_API
extern "C" void LIBRARY_API hello();
void hello() { std::cout << "Hello, world!" << std::endl; }
  • lib/CMakeLists.txt
aux_source_directory(. DIR_LIB_SRCS)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) 
add_library(TestLibrary SHARED ${DIR_LIB_SRCS}) 
  • 根目录下CMakeLists.txt
cmake_minimum_required(VERSION 2.80)

project(poco)

SET(Poco_DIR /usr/lib/) 
SET(Poco_INCLUDE_DIRS /usr/include/Poco) 
SET(Poco_LIBRARIES /usr/lib/libPocoFoundation.so)

add_subdirectory(src)
add_subdirectory(lib)
  • 输出结果
    在这里插入图片描述

导出类

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
(注:若需要下载帮助文档,请搜索poco-1.6.1-all-doc) 本资源介绍:Introduction The POCO C++ Libraries are a collection of open source C++ class libraries that simplify and accelerate the development of network-centric, portable applications in C++. The libraries integrate perfectly with the C++ Standard Library and fill many of the functional gaps left open by it. Their modular and efficient design and implementation makes the POCO C++ Libraries extremely well suited for embedded development, an area where the C++ programming language is becoming increasingly popular, due to its suitability for both low-level (device I/O, interrupt handlers, etc.) and high-level object-oriented development. Of course, POCO is also ready for enterprise-level challenges. POCO Libraries POCO consists of four core libraries, and a number of add-on libraries. The core libraries are Foundation, XML, Util and Net. Two of the add-on libraries are NetSSL, providing SSL support for the network classes in the Net library, and Data, a library for uniformly accessing different SQL databases. POCO aims to be for network-centric, cross-platform C++ software development what Apple's Cocoa is for Mac development, or Ruby on Rails is for Web development — a powerful, yet easy and fun to use platform to build your applications upon. POCO is built strictly using standard ANSI/ISO C++, including the standard library. The contributors attempt to find a good balance between using advanced C++ features and keeping the classes comprehensible and the code clean, consistent and easy to maintain.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海洋2416

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值