开源项目推荐:POCO C++ Libraries大全,含MFC的编译及使用
发布日期:2021-06-30 18:20:44 浏览次数:3 分类:技术文章

本文共 3051 字,大约阅读时间需要 10 分钟。

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.

 

1、官网

 

2、教程

 VS2013安装

 MFC中引入POCO库之后找不到API的问题

在MFC项目中加入POCO库,导致MFC中的部分方法找不到。 

比如: 

error C3861: “GetObject”: 找不到标识符 

error C3861: “CreateFile”: 找不到标识符

解决办法:

在\Foundation\include\Poco\UnWindows.h文件中的注释部分已经说明。 

方法1、使用对应方法的Unicode变体(e.g., GetUserNameW)和ASCII变体(GetUserNameA
方法2、使用POCO_NO_UNWINDOWS的宏定义
VC++属性页预编译头添加变量:

_CRT_SECURE_NO_WARNINGS

POCO_NO_UNWINDOWS

推荐方法1

另外,多关注一下

\Foundation\include\Poco\Config.h,里面有C++11的开关

// without POCO_WIN32_UTF8 defined on Windows is deprecated.

//#define POCO_WIN32_UTF8
// Define to enable C++11 support
#define POCO_ENABLE_CPP11

\Foundation\include\Poco\Platform_WIN32.h

 

3、我的编译方式

(1)新建空项目

(2)手动添加自己需要的库

 

4、我使用MFC遇到的内存泄露问题:

我是在MFC使用POCO库的,std:string存在内存泄露,解决方法是:

Build poco with MFC Extension DLLs projects, not the windows DLL, then it can used with VC++/MFC
参考

说白了,就是

(1)poco的项目属性页,常规,MFC的使用,选择“在共享 DLL 中使用 MFC”。

(2)poco项目属性页,链接器,输入,附加依赖库,添加Advapi32.lib

Advapi32.lib很重要,否则编译会报错:

1>正在生成代码...

1>  正在创建库 ..\lib\PocoFoundationd.lib 和对象 ..\lib\PocoFoundationd.exp
1>EventLogChannel.obj : error LNK2019: 无法解析的外部符号 __imp__DeregisterEventSource@4,该符号在函数 "public: virtual void __thiscall Poco::EventLogChannel::close(void)" (?close@EventLogChannel@Poco@@UAEXXZ) 中被引用
1>EventLogChannel.obj : error LNK2019: 无法解析的外部符号 __imp__RegisterEventSourceA@8,该符号在函数 "public: virtual void __thiscall Poco::EventLogChannel::open(void)" (?open@EventLogChannel@Poco@@UAEXXZ) 中被引用
1>EventLogChannel.obj : error LNK2019: 无法解析的外部符号 __imp__ReportEventA@36,该符号在函数 "public: virtual void __thiscall Poco::EventLogChannel::log(class Poco::Message const &)" (?log@EventLogChannel@Poco@@UAEXABVMessage@2@@Z) 中被引用
1>EventLogChannel.obj : error LNK2019: 无法解析的外部符号 __imp__RegCloseKey@4,该符号在函数 __catch$??1EventLogChannel@Poco@@MAE@XZ$0 中被引用
1>EventLogChannel.obj : error LNK2019: 无法解析的外部符号 __imp__RegCreateKeyExA@36,该符号在函数 __catch$??1EventLogChannel@Poco@@MAE@XZ$0 中被引用
1>EventLogChannel.obj : error LNK2019: 无法解析的外部符号 __imp__RegSetValueExA@24,该符号在函数 __catch$??1EventLogChannel@Poco@@MAE@XZ$0 中被引用
1>RandomStream.obj : error LNK2019: 无法解析的外部符号 __imp__CryptAcquireContextA@20,该符号在函数 "public: virtual int __thiscall Poco::RandomBuf::readFromDevice(char *,__int64)" (?readFromDevice@RandomBuf@Poco@@UAEHPAD_J@Z) 中被引用
1>RandomStream.obj : error LNK2019: 无法解析的外部符号 __imp__CryptReleaseContext@8,该符号在函数 "public: virtual int __thiscall Poco::RandomBuf::readFromDevice(char *,__int64)" (?readFromDevice@RandomBuf@Poco@@UAEHPAD_J@Z) 中被引用
1>RandomStream.obj : error LNK2019: 无法解析的外部符号 __imp__CryptGenRandom@12,该符号在函数 "public: virtual int __thiscall Poco::RandomBuf::readFromDevice(char *,__int64)" (?readFromDevice@RandomBuf@Poco@@UAEHPAD_J@Z) 中被引用
1>..\bin\PocoFoundationd.dll : fatal error LNK1120: 9 个无法解析的外部命令
1>已完成生成项目“Foundation_vs140.vcxproj”的操作 - 失败。

 

---

题外话:

1、介绍一个国产的C++库:ACL,跨平台,大而全

One advanced C/C++ library for Linux, Mac, FreeBSD, Solaris(x86), Windows, Android, IOS 

2、C++库大全

 

转载地址:https://libaineu2004.blog.csdn.net/article/details/90608002 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:开源项目推荐:Dlib C++ Libraries使用说明与内存泄漏问题解决(★firecat推荐★)
下一篇:MFC自定义消息发送机制及CString对象作为消息发送(我误认为PostMessage发了多次,其实没有)

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月17日 08时05分07秒