Search code examples
c++visual-studio-2010linkerlnk2019

"unresolved external symbol _triangulate" when using triangle library


I'm currently using the triangle library in my program. The library contains only .c and .h files (no .lib). I get the following error on Visual Studio C++ 2010:

    1>data.obj : error LNK2019: unresolved external symbol _triangulate referenced in function "struct triangulateio __cdecl readfile(void)" (?readfile@@YA?AUtriangulateio@@XZ)

The header file of my data.cpp is the following:

#ifndef DATA_H
#define DATA_H

#include <WinSock2.h>

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <string>
#include <time.h>
#include <GL/gl.h> //include the gl header file
#include <GL/glut.h> //include the glut header file
#include <GL/glu.h> //include the glut header file
#include <armadillo>

//Namespace
using namespace std;
using namespace arma;

extern "C"
{
    #ifdef SINGLE
    #define REAL float
    #else /* not SINGLE */
    #define REAL double
    #endif /* not SINGLE */

    #include "triangle.h"
}
triangulateio readfile();

#endif

Data.cpp

 triangulate("pczAevn", &in, &mid, &vorout);

I've already made my program work with a Makefile of mine on Ubuntu, but I need to run my program on windows. Feel free to ask for more information.

EDIT #1: If you use the triangle library with VS, you have to put the following instruction on top of the triangle.c file #define TRILIBRARY Now it compile. Thank you very much for the help.


Solution

  • The linker can't find a definition for "triangulateio readfile()", if it's defined in the .c file my guess is that it isn't built. If you include it in the project it could work.