I have a similar question so I thought I would necro this thread.
I'm a math student trying to write a program so I don't know too much. I'm working on fedora code 5.
I am trying to make a call to a C program called nauty (it calculates automorphism groups of graphs).
As a first step I'm just trying to run one of it's example programs, which executes a simple call to nauty.
However it says "It needs to be linked with nauty.c nautil.c and naugraph.c.".
I've got a vague idea of what that means from reading around here a little bit.
When I try to compile my example program I get a whole host of errors. It seems that the example cannot find nauty. This isn't too suprising since nauty is in a different folder.
So my question is: how do I link my example program to other c files that are located elsewhere?
Here is the example program in full.
The nauty files are in /usr/local/nauty22
Code:
/* This program prints generators for the automorphism group of an
n-vertex polygon, where n is a number supplied by the user.
It needs to be linked with nauty.c, nautil.c and naugraph.c.
This version uses a fixed limit for MAXN.
*/
#define MAXN 100
#include "nauty.h" /* which includes <stdio.h> */
main()
{
graph g[MAXN*MAXM];
int lab[MAXN],ptn[MAXN],orbits[MAXN];
static DEFAULTOPTIONS(options);
statsblk(stats);
setword workspace[50*MAXM];
int n,m,v;
set *gv;
options.writeautoms = TRUE;
while (1)
{
printf("\nenter n : ");
if (scanf("%d",&n) == 1 && n > 0)
{
if (n > MAXN)
{
printf("n must be in the range 1..%d\n",MAXN);
exit(1);
}
m = (n + WORDSIZE - 1) / WORDSIZE;
nauty_check(WORDSIZE,m,n,NAUTYVERSIONID);
for (v = 0; v < n; ++v)
{
gv = GRAPHROW(g,v,m);
EMPTYSET(gv,m);
ADDELEMENT(gv,(v+n-1)%n);
ADDELEMENT(gv,(v+1)%n);
}
printf("Generators for Aut(C[%d]):\n",n);
nauty(g,lab,ptn,NULL,orbits,&options,&stats,
workspace,50*MAXM,m,n,NULL);
}
else
break;
}
}
Hopefully I havn't broken any protocal here.
Thanks very much for any and all advice.