无法使用twitcurl编译程序 [英] Unable to compile program with twitcurl

查看:61
本文介绍了无法使用twitcurl编译程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Linux上使用Twitter库编译C ++程序.

I want to compile a C++ program with a twitter library, on Linux.

我目前正在使用twitcurl作为Twitter API库,并安装了g ++以及官方网站上列出的所有必要文件和软件包:

I'm current using twitcurl as the twitter API library and installed g++ and all the necessary files and packages that are listed on the official website: http://code.google.com/p/twitcurl/wiki/WikiHowToUseTwitcurlLibrary

但是,当我使用此命令 g ++ twitterClient.cpp -ltwitcurl 编译程序时,出现以下错误:找不到-ltwitcurl

However, when I compile my program using this command g++ twitterClient.cpp -ltwitcurl, I get this error: cannot find -ltwitcurl

我还使用CodeBlocks IDE对其进行了编译,但出现了以下错误:对twitCurl ::〜twitCurl()的未定义引用`

I also used CodeBlocks IDE to compile it but got this error: undefined reference to twitCurl::~twitCurl() `

我的代码仅包含几行:

#include <iostream>
#include "Twitter/Twitter.hpp"
using namespace std ;

int main ()
{
    Twitter t ;
    return 0 ; 
}

我已经在这方面花费了大量时间,但无法解决问题.为了在命令行和CodeBlocks上编译程序,我该怎么做?

I've already spent a lot of time on this but am unable to solve the problem. What should I do in order to compile the program on the command-line and CodeBlocks?

推荐答案

$ g++ twitterClient.cpp -ltwitcurl
cannot find -ltwitcurl

这意味着您的编译器在其库目录中找不到 libtwitcurl.so.1..

This means your compiler doesn't find the libtwitcurl.so.1. in its library directories.

首先,请确保您正确构建了 twitcurl 库,并使用以下内容获取了 libtwitcurl.so.1.文件:

First, make sure you correctly build the twitcurl library and obtained the libtwitcurl.so.1. file with something like this :

svn co http://twitcurl.googlecode.com/svn/trunk/libtwitcurl
cd libtwitcurl/
make

第二,确保将文件(或符号链接)放在编译器的库路径之一中:

Secondly, make sure you put the file (or a symlink) in one of your compiler's library path :

cp libtwitcurl.so.1.0 /usr/lib/

您可以使用以下命令检查g ++库路径:

You can check g++ library paths using the following command :

g++ --print-search-dirs | grep libraries

(/usr/lib/通常在末尾.)

如果您不想/不能将文件放在编译器的库路径中,则还可以通过添加 -L来告诉它在哪里找到 libtwitcurl.so.1..g ++选项中的/path/to/twitcurl/,但是如果文件已经在编译器的库路径之一中,则不需要此文件.

If you don't want/can't put the file in your compiler's library path, you can also tell it where to find libtwitcurl.so.1. by adding -L/path/to/twitcurl/ in the g++ options, but it is not needed if the file is already in one of the compiler's library path.

这篇关于无法使用twitcurl编译程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆