igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] compiling igraph C under linux


From: Gábor Csárdi
Subject: Re: [igraph] compiling igraph C under linux
Date: Thu, 17 Nov 2011 10:48:02 -0500

You need to specify that you are linking against the igraph library, e.g.

g++ -I/usr/include/igraph -L/usr/lib/ -ligraph igraphTest.cc

You might need to change /usr/lib to the library where you have igraph
installed.

Btw. this seems to be C code. Any reason for compiling it with a C++ compiler?

Gabor

On Thu, Nov 17, 2011 at 10:34 AM, Galen Wilkerson <address@hidden> wrote:
> Hi,
>
> I am compiling a small sample igraph program as follows and getting
> the following error:
>
> $ g++ -I/usr/include/igraph igraphTest.cc
> /tmp/ccDMytBa.o: In function `main':
> igraphTest.cc:(.text+0x36): undefined reference to `igraph_erdos_renyi_game'
> igraphTest.cc:(.text+0x69): undefined reference to `igraph_diameter'
> igraphTest.cc:(.text+0x8c): undefined reference to `igraph_destroy'
> collect2: ld returned 1 exit status
>
> ----------------------------------------------------------------
> The program:
>
> #include <igraph.h>
>
> int main(void)
> {
>  igraph_real_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: %f\n",
>         (double) diameter);
>  igraph_destroy(&graph);
>  return 0;
> }
>
> -------------------------------------------------------------------------------------------------
>
> Looking in /usr/include/igraph:
>
> /usr/include/igraph$ grep igraph_erdos_renyi_game *
> igraph.h:int igraph_erdos_renyi_game(igraph_t *graph, igraph_erdos_renyi_t 
> type,
> igraph.h:int igraph_erdos_renyi_game_gnp(igraph_t *graph,
> igraph_integer_t n, igraph_real_t p,
> igraph.h:int igraph_erdos_renyi_game_gnm(igraph_t *graph,
> igraph_integer_t n, igraph_real_t m,
>
> -------------------------------------------------------------------------------------------------
> system info:
>
> $ uname -a
> Linux erzsebet 2.6.32-33-server #72-Ubuntu SMP Fri Jul 29 21:21:55 UTC
> 2011 x86_64 GNU/Linux
>
>
> thanks very much for any help,
> best,
> Galen
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     MTA KFKI RMKI



reply via email to

[Prev in Thread] Current Thread [Next in Thread]