Hi,
I have Structure in C, program and the structure is being used with
various function inside C coding but am getting undefined referenced
to global method and few of them too uses the sturct module.
my problem goes like this,

ex.h
-----------
#define NIL 0                   /* Indicates ptr is nil */
#define NO_CODER 0              /* Means do not use an arithmetic
coder */
#define DEFAULT_CODER 1         /* Default arithmetic coder */
#define FALSE 0                 /* For boolean expressions */
#define TRUE 1                  /* For boolean expressions */

typedef unsigned int boolean;
extern unsigned int debugModel;

typedef struct debugType
{
   unsigned int level;
   unsigned int level1;
   unsigned int progress;
   unsigned int range;
   unsigned int coder;
   unsigned int coder_target;
   unsigned int codelengths;
}debugType;
extern struct debugType Debug;

//main function for .c file
void usage(void);
void loadModels(FILE *fp);
void init_arguments(int argc, char *argv[]);
unsigned int *getText (FILE *fp, unsigned int eoln, unsigned int
del_last_eoln, unsigned int *len);
float codelengthText (unsigned int model, unsigned int *text, unsigned
int textlen);
void codelengthModels (unsigned int *text, unsigned int textlen);

//gloabal function for .c file running with local function
extern unsigned int TLM_create_context (unsigned int model);
extern void TLM_set_context_operation (unsigned int
context_operation);
extern void TLM_update_context (unsigned int model, unsigned int
context, unsigned int symbol);
extern void TLM_release_context (unsigned int model, unsigned int
context);
extern void TLM_dump_models (unsigned int file, void
(*dump_symbol_function) (unsigned int, unsigned int));
extern void TLM_set_tag (unsigned int model, char *tag);
---------------------------------------------------------------------
ex.c
--------
#include "ex.h"
int Exclude_eolns = 0;    /* For incuding/excluding eolns in the input
*/
int Delete_last_eoln = 0; /* For deleting the last eoln read in from
the input */
int Debug_model = 0;      /* For dumping out the model */
int Debug_chars = 0;      /* For dumping out the codelength character
by character */
int Display_entropy = 0;  /* For displaying cross-entropies and not
codelengths */

unsigned int TLM_Coderanges;
float TLM_Codelength;
unsigned int TLM_Context_Operation;


void loadModels (FILE * fp)
/* Load the models from file FP. */
{
   char tag [MAX_TAG], filename [MAX_FILENAME];
    //char tag [256], filename [256];

    unsigned int model;

    while ((fscanf (fp, "%s %s", tag, filename) != EOF))
    {
        model = TLM_read_model(filename, "Loading model from file",
"Codelength: can't open model file");
        TLM_set_tag (model, tag);
    }
}

void init_arguments (int argc, char *argv[])
{
    char *optarg; //extern char *optarg;
    int optind; //extern int optind;
    FILE *fp;
    unsigned int models_found;
    int opt;

    /* get the argument options */

    models_found = 0;
    Exclude_eolns = 0;
    Delete_last_eoln = 1;
    while ((opt = getopt (argc, argv, "ELcd:em:r")) != -1)
        switch (opt)
        {
        case 'E':
            Exclude_eolns = 1;
            break;
        case 'L':
            Delete_last_eoln = 1;
            break;
        case 'c':
            Debug_chars = 1;
            break;
        case 'd':
            Debug_model = atoi (optarg);
            break;
        case 'e':
            Display_entropy = 1;
            break;
        case 'm':
            fprintf (stderr, "Loading models from file %s\n",
                    optarg);
            if ((fp = fopen (optarg, "r")) == NULL)
            {
                fprintf (stderr, "Encode: can't open models file %s\n",
                         optarg);
                exit (1);
            }
            loadModels (fp);
            models_found = 1;
            break;
        case 'r':
            Debug.range = 1; //uses structure element range.
            break;
        default:
            usage ();
            break;
        }
    if (!models_found)
    {
        fprintf (stderr, "\nFatal error: missing models\n\n");
        usage ();
    }
    for (; optind < argc; optind++)
        usage ();
}
----------------------------------------------------------------------------------------------------------------------------------

but while running setup.py build with distutils it's showing error as

_ex.o: In function 'init_arguments':
     _ex.c :89: undefined reference to _TLM_read_model
     _ex.c :95:  undefined reference to _TLM_set_tag

for all the global function declared within .h file and the calling
method from .c file,
also how can the Debug.range can be used...

thank's
anish
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to