【问题标题】:Installing the library "IGRAPH" for C/C++ in application folder在应用程序文件夹中安装 C/C++ 库“IGRAPH”
【发布时间】:2013-11-10 09:18:40
【问题描述】:

在应用程序文件夹中安装 C/C++ 库“IGRAPH”时出现问题

我使用的是 Ubuntu 13.04

下载链接:http://sourceforge.net/projects/igraph/?source=dlp

我正在尝试根据此链接为 C/C++ 安装库“IGRAPH”:

http://igraph.sourceforge.net/doc/html/igraph-installation.html

http://igraph.sourceforge.net/doc/html/ch03s01.html

http://www.linphone.org/docs/mediastreamer2/mediastreamer2_install.html 参见“安装名称”部分

基本,安装完整的C库打字

$ ./configure
$ make
$ make install

默认情况下,'make install'/usr/local/bin 下安装包的命令,在/usr/local/include 下包含文件等。我想将包安装在我的应用程序目录中

我修改了默认安装:

$ ./configure
$ make
$ make install DESTDIR=~/Desktop/Graph/igraph/

我正在尝试编译以下简短的示例程序:

#include "../usr/local/include/igraph/igraph.h"

int main(void) {
    igraph_integer_t diameter;
    igraph_t graph;
    igraph_erdos_renyi_game(&graph, IGRAPH_ERDOS_RENYI_GNP, 1000, 5.0/1000, IGRAPH_UNDIRECTED, IGRAPH_NO_LOOPS);
    igraph_diameter(&graph, &diameter, 0, 0, 0, IGRAPH_UNDIRECTED, 1);
    printf("Diameter of a random graph with average degree 5: %d\n", (int) diameter);
    igraph_destroy(&graph);
    return 0;
}

我正在使用命令编译程序:

gcc igraph_test.c -I~/Desktop/Graph/igraph/usr/local/include/igraph -L~/Desktop/Graph/igraph/usr/local/lib -ligraph -o igraph_test

但是,出现了这个错误:

/usr/bin/ld: cannot find -ligraph
collect2: error: ld returned 1 exit status

谁能帮帮我?

【问题讨论】:

  • 这是您正在编译的实际代码,以及它给出的实际错误吗?或者您的真实代码是否在第 8 行显示 GRAPH_UNDIRECTED,而它应该(可能)显示 IGRAPH_UNDIRECTED
  • 对不起,错误是另一个。修正问题。
  • 您是否检查过安装确实将库放置在您期望的位置? IE。 ~/Desktop/Graph/igraph/usr/local/lib 中有 libigraph.a.so 吗?
  • 是的,所有文件都在这个目录下。有:~/Desktop/Graph/igraph/usr/local/lib e ~/Desktop/Graph/igraph/usr/local/include/igraph
  • 我试过pkg-config --libs --cflags ~/Desktop/Graph/igraph/usr/local/include/igraph,但没用。

标签: c++ c ubuntu igraph


【解决方案1】:

当您调用gcc 时,请尝试拼出主目录的全名(例如/Users/whatever/Desktop/Graph/igraph/usr/local/lib),而不是简单地指定~/Desktop/Graph/igraph/usr/local/lib。对~/Desktop/Graph/igraph/usr/local/include 执行相同操作。这解决了我机器上的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多