title: Error: C++ unresolved external symbol
body: <p>I am currently using two C files written by others in my C++ project in Visual&nbsp;Studio&nbsp;2008 (actually, it is provided free online as a polygon intersection library).</p>
  
  <p>The two files I downloaded are gcp.h and gcp.c. So I copied gcp.h and gcp.c to my project directory. The linker gave me this error:</p>
  
  <blockquote>
    <p>unresolved external symbol: void __cdecl gpc_polygon_clip(enum gpc_op,struct gpc_polygon *,struct gpc_polygon *,struct gpc_polygon *)</p>
  </blockquote>
  
  <p>Below is how wrote my code which uses the library:</p>
  
  <pre><code>static int poly_intersection(Convex_Polygon&amp; poly1,Convex_Polygon&amp; poly2,Convex_Polygon&amp; rp)
  {
      if(!poly1.is_convex() || !poly2.is_convex())
          return 1;
  
      // Construct 1st convex polygon
      gpc_vertex *gvp1 = new gpc_vertex[poly1.size()];
      gpc_vertex v1;
      for (unsigned int n = 0; n &lt; poly1.size(); n++)
      {
          v1.x = poly1.vertex(n).x();
          v1.y = poly1.vertex(n).y();
          gvp1[n] = v1;
      }
  
      gpc_vertex_list gvl1;
      gvl1.num_vertices = poly1.size();
      gvl1.vertex = gvp1;
  
      gpc_vertex_list *gvlp1 = new gpc_vertex_list[1];
      gvlp1[0] = gvl1;
  
      gpc_polygon gp1;
      gp1.num_contours = 1;
      gp1.hole = 0;
      gp1.contour = gvlp1;
  
      // Construct 2st convex polygon
      gpc_vertex *gvp2 = new gpc_vertex[poly2.size()];
      gpc_vertex v2;
      for (unsigned int n = 0; n &lt; poly2.size(); n++)
      {
          v2.x = poly2.vertex(n).x();
          v2.y = poly2.vertex(n).y();
          gvp2[n] = v2;
      }
  
      gpc_vertex_list gvl2;
      gvl2.num_vertices = poly2.size();
      gvl2.vertex = gvp2;
  
      gpc_vertex_list *gvlp2 = new gpc_vertex_list[1];
      gvlp2[0] = gvl2;
  
      gpc_polygon gp2;
      gp2.num_contours = 1;
      gp2.hole = 0;
      gp2.contour = gvlp2;
  
      // Do convex polygon intersection
      gpc_polygon result;
      gpc_polygon_clip(GPC_INT, &amp;gp1, &amp;gp2, &amp;result);
  </code></pre>
  
  <p>And for clarity, the content of the two files I used are</p>
  
  <pre><code>#gcp.h
  
  #define GPC_EPSILON (DBL_EPSILON)
  #define GPC_VERSION "2.32"
  
  /*
  ===========================================================================
                             Public Data Types
  ===========================================================================
  */
  
  typedef enum                        /* Set operation type                */
  {
    GPC_DIFF,                         /* Difference                        */
    GPC_INT,                          /* Intersection                      */
    GPC_XOR,                          /* Exclusive or                      */
    GPC_UNION                         /* Union                             */
  } gpc_op;
  
  typedef struct                      /* Polygon vertex structure          */
  {
    double              x;            /* Vertex x component                */
    double              y;            /* vertex y component                */
  } gpc_vertex;
  
  typedef struct                      /* Vertex list structure             */
  {
    int                 num_vertices; /* Number of vertices in list        */
    gpc_vertex         *vertex;       /* Vertex array pointer              */
  } gpc_vertex_list;
  
  typedef struct                      /* Polygon set structure             */
  {
    int                 num_contours; /* Number of contours in polygon     */
    int                *hole;         /* Hole / external contour flags     */
    gpc_vertex_list    *contour;      /* Contour array pointer             */
  } gpc_polygon;
  
  typedef struct                      /* Tristrip set structure            */
  {
    int                 num_strips;   /* Number of tristrips               */
    gpc_vertex_list    *strip;        /* Tristrip array pointer            */
  } gpc_tristrip;
  
  
  /*
  ===========================================================================
                         Public Function Prototypes
  ===========================================================================
  */
  
  void gpc_read_polygon        (FILE            *infile_ptr,
                                int              read_hole_flags,
                                gpc_polygon     *polygon);
  
  void gpc_write_polygon       (FILE            *outfile_ptr,
                                int              write_hole_flags,
                                gpc_polygon     *polygon);
  
  void gpc_add_contour         (gpc_polygon     *polygon,
                                gpc_vertex_list *contour,
                                int              hole);
  
  void gpc_polygon_clip        (gpc_op           set_operation,
                                gpc_polygon     *subject_polygon,
                                gpc_polygon     *clip_polygon,
                                gpc_polygon     *result_polygon);
  
  void gpc_tristrip_clip       (gpc_op           set_operation,
                                gpc_polygon     *subject_polygon,
                                gpc_polygon     *clip_polygon,
                                gpc_tristrip    *result_tristrip);
  
  void gpc_polygon_to_tristrip (gpc_polygon     *polygon,
                                gpc_tristrip    *tristrip);
  
  void gpc_free_polygon        (gpc_polygon     *polygon);
  
  void gpc_free_tristrip       (gpc_tristrip    *tristrip);
  
  #endif
  </code></pre>
  
  <p>Before my own method at the beginning of my C++ header file, I put #include "gpc.h", which I thought would take care of it. But it didn't work.</p>
  
  <p><img src="https://i.stack.imgur.com/44tqr.jpg" alt="This is the file structure of my project"></p>