首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法编译此poco程序。

无法编译此poco程序。
EN

Stack Overflow用户
提问于 2020-05-24 20:00:36
回答 1查看 581关注 0票数 1

我从github克隆了poco库,并执行了repo中的文件build_cmake.sh。在执行build_cmake.sh file.It时没有出现任何问题,而是在/usr/local/file.It目录中创建了许多头文件。

代码语言:javascript
复制
#include "Poco/DateTime.h"
#include "Poco/Timespan.h"
#include<iostream>
using Poco::DateTime;
using Poco::Timespan;
using namespace std;
int main(int argc, char** argv)
{
        // what is my age?
        DateTime birthdate(1995, 02, 16, 2, 30); // 1973-09-12 02:30:00 //date of birth 
                                 //and time in following format YYYY, MM, DD, hh, mm, ss


        DateTime now;

        Timespan age = now - birthdate;
        int days = age.days(); // in days
        int hours = age.totalHours(); // in hours
        int secs = age.totalSeconds(); // in seconds

        cout << "iNDays: You are  " << days << " days older." << endl;
        cout << "iNHours: You are " << hours << " hours older. " << endl;
        cout << "iNSeconds: You are " << secs << " seconds older" << endl;

        return 0;
}

现在,如果我使用

代码语言:javascript
复制
g++ filename.cpp

我得到以下错误。

代码语言:javascript
复制
/usr/bin/ld: /tmp/cc187sFs.o: in function `main':
timeSpace.cpp:(.text+0x4c): undefined reference to `Poco::DateTime::DateTime(int, int, int, int, int, int, int, int)'
/usr/bin/ld: timeSpace.cpp:(.text+0x5c): undefined reference to `Poco::DateTime::DateTime()'
/usr/bin/ld: timeSpace.cpp:(.text+0x73): undefined reference to `Poco::DateTime::operator-(Poco::DateTime const&) const'
/usr/bin/ld: timeSpace.cpp:(.text+0x192): undefined reference to `Poco::DateTime::~DateTime()'
/usr/bin/ld: timeSpace.cpp:(.text+0x19e): undefined reference to `Poco::DateTime::~DateTime()'
/usr/bin/ld: timeSpace.cpp:(.text+0x1d1): undefined reference to `Poco::DateTime::~DateTime()'
/usr/bin/ld: timeSpace.cpp:(.text+0x1e2): undefined reference to `Poco::DateTime::~DateTime()'
/usr/bin/ld: /tmp/cc187sFs.o: in function `Poco::Timespan::days() const':
timeSpace.cpp:(.text._ZNK4Poco8Timespan4daysEv[_ZNK4Poco8Timespan4daysEv]+0x12): undefined reference to `Poco::Timespan::DAYS'
/usr/bin/ld: /tmp/cc187sFs.o: in function `Poco::Timespan::totalHours() const':
timeSpace.cpp:(.text._ZNK4Poco8Timespan10totalHoursEv[_ZNK4Poco8Timespan10totalHoursEv]+0x12): undefined reference to `Poco::Timespan::HOURS'
/usr/bin/ld: /tmp/cc187sFs.o: in function `Poco::Timespan::totalSeconds() const':
timeSpace.cpp:(.text._ZNK4Poco8Timespan12totalSecondsEv[_ZNK4Poco8Timespan12totalSecondsEv]+0x12): undefined reference to `Poco::Timespan::SECONDS'
collect2: error: ld returned 1 exit status

谁能给出详细的步骤如何安装poco库和运行poco程序。

EN

回答 1

Stack Overflow用户

发布于 2020-06-11 00:22:49

由于您已经生成了POCO库,所以可以包括如下所示的标题:

代码语言:javascript
复制
#include <Poco/DateTime.h>

您应该像这样链接所需的POCO库:

代码语言:javascript
复制
g++ filename.cpp -lPocoFoundation -lPocoUtil
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61991737

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档