0

在应用程序文件夹中为 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

谁能帮我?

4

1 回答 1

1

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

于 2013-10-30T17:23:46.787 回答