Thread: Working with multiple source files

  1. #16
    Registered User
    Join Date
    Jun 2008

    Similar situation

    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
    /* 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> */
        graph g[MAXN*MAXM];
        int lab[MAXN],ptn[MAXN],orbits[MAXN];
        static DEFAULTOPTIONS(options);
        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);
                m = (n + WORDSIZE - 1) / WORDSIZE;
                for (v = 0; v < n; ++v)
                    gv = GRAPHROW(g,v,m);
                printf("Generators for Aut(C[%d]):\n",n);
    Hopefully I havn't broken any protocal here.
    Thanks very much for any and all advice.

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    You would type "gcc" followed by all the .c files needed to make a complete program. If they are in different directories, you can specify a path to those files, or move all the .c files so they are together.

  3. #18
    Registered User
    Join Date
    Jun 2008
    Thanks very much, I appreaciate it ^^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Splitting source into multiple files(Linux & make)
    By IceDane in forum C Programming
    Replies: 6
    Last Post: 05-18-2009, 07:31 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. WM_COPYDATA and mutex selecting multiple files
    By gh0st in forum Windows Programming
    Replies: 2
    Last Post: 10-27-2006, 02:22 PM
  4. multiple source files
    By AmazingRando in forum C Programming
    Replies: 6
    Last Post: 03-13-2005, 03:39 PM
  5. Multiple Source Files!?!?
    By Padawan in forum C Programming
    Replies: 14
    Last Post: 04-04-2004, 12:19 AM

Tags for this Thread