'Keywords' 不是名称空间名称

'Keywords' is not a namespace-name

我是一个半正经的 Java/C# 程序员,在 C++/PoCo 上苦苦挣扎。

到目前为止我看到的所有示例都具有相同的行。 使用命名空间 Poco::Data::Keywords; 在QT中,"Keywords"部分是黑色的。如果可以解决这个问题,我不知道要“#include”什么。 Codeblocks 也因同样的错误而失败 => 'Keywords' is not a namespace-name

一个小例子:

#include <Poco/Format.h>
#include <Poco/Data/MySQL/MySQLException.h>
#include <Poco/Data/Session.h>
#include <Poco/Data/MySQL/Connector.h>
using namespace Poco::Data::Keywords;

int main(int argc, char** argv){
    return 0;
}

我已经在几台电脑上试过了。目前的一个是 Ubuntu 15.10,已更新并具有以下软件包(包括 libpoco)+ MySQL Client/Server/Workbench。

    1  sudo apt-get install build-essential 
    2  sudo apt-get install qtbase5-dev qtbase5-dev-tools qtbase5-doc   qtbase5-doc-html qtbase5-examples qtbase5-examples-dbg
    3  sudo apt-get install qt5-default qt5-doc-html qt5-doc
    4  sudo apt-get install openssl libssl-dev libssl-doc 
    5  sudo apt-get install libpoco-dev

也许您的库版本比您正在使用的实际文档中的版本旧。 尝试使用此命令查找版本:

grep "POCO_VERSION" /usr/include/Poco/*.h

对我来说它输出:

/usr/include/Poco/Foundation.h:#define POCO_VERSION 0x01030600

这意味着 poco 只有 1.3(还没有关键字命名空间)而不是 1.5(有关键字命名空间)。

如果您需要最新的 Poco,您可以手动下载并安装它,而不是使用 apt。