unresolved external symbol

Hardly a new error message :) I would really appreciate some help in cracking this nut thought...

I have 2 projects; the first contains a header file and a .c file. I have not written this code. The c file is +16000 lines. The header file is simple:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#define ANSI_DECLARATORS

#define SINGLE

#ifdef SINGLE
#define REAL float
#else /* not SINGLE */
#define REAL double
#endif /* not SINGLE */


struct triangulateio {
  REAL *pointlist;                                               /* In / out */
  REAL *pointattributelist;                                      /* In / out */
  int *pointmarkerlist;                                          /* In / out */
  int numberofpoints;                                            /* In / out */
  int numberofpointattributes;                                   /* In / out */

  int *trianglelist;                                             /* In / out */
  REAL *triangleattributelist;                                   /* In / out */
  REAL *trianglearealist;                                         /* In only */
  int *neighborlist;                                             /* Out only */
  int numberoftriangles;                                         /* In / out */
  int numberofcorners;                                           /* In / out */
  int numberoftriangleattributes;                                /* In / out */

  int *segmentlist;                                              /* In / out */
  int *segmentmarkerlist;                                        /* In / out */
  int numberofsegments;                                          /* In / out */

  REAL *holelist;                        /* In / pointer to array copied out */
  int numberofholes;                                      /* In / copied out */

  REAL *regionlist;                      /* In / pointer to array copied out */
  int numberofregions;                                    /* In / copied out */

  int *edgelist;                                                 /* Out only */
  int *edgemarkerlist;            /* Not used with Voronoi diagram; out only */
  REAL *normlist;                /* Used only with Voronoi diagram; out only */
  int numberofedges;                                             /* Out only */
};

#ifdef ANSI_DECLARATORS
extern void triangulate(char *, struct triangulateio *, struct triangulateio *, struct triangulateio *);
extern void trifree(void *memptr);
#else /* not ANSI_DECLARATORS */
void triangulate();
void trifree();
#endif /* not ANSI_DECLARATORS */ 


I have compiled this as a static lib (.lib).

The second project contains a cpp class with a header file and a .cpp file. I have linked to the first project by
1) adding #include to the header file from the first project (see above)
2) linking to the .lib file

When I compile (I have tried with both Visual studio and gcc) I get 'unresolved external symbol' when using the triangulate method.

Can anybody see that the problem is?

Thx in advance
Where is the definition of the function void triangulate(char *, struct triangulateio *, struct triangulateio *, struct triangulateio *); ?
It's in the +16000 lines triangle.c file.
I've just tried changing the extension of the file (triangle.c -> triangle.cpp) and now it compiles fine in both vc++ and gcc. I have no idea why, but it took me all morning to figure it out.
Thx for you interest.
If you don't specify the language used, the compilers will guess based on the filename extension.

C and C++ use different naming conventions for the symbols in the object files - http://en.wikipedia.org/wiki/Name_mangling

Topic archived. No new replies allowed.