2

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.

user1118321
  • 25,567
  • 4
  • 55
  • 86
arnaud13
  • 109
  • 1
  • 2
  • 11
  • have you added the .lib file to the visual studio project's linker settings? – Jimmy Sep 11 '12 at 18:02
  • There is no lib; it's just a .c and a .h file. – Joe Sep 11 '12 at 18:04
  • What is 'readfile'? Is that your code? You might need to show your declarations of in, mid, vorout. – Joe Sep 11 '12 at 18:07
  • might I suggest using mingw to compile on Windows? your makefile might work as-is. Otherwise, have you tried putting your declaration of read file in your extern "C" and compiling then? – Jimmy Sep 11 '12 at 18:17
  • readfile is a function I've created, it's not part of the library. Putting readfile in extern C didn't work. `struct triangulateio in, mid, out, vorout;` I'd love to compile it on windows but I need to use VS because of compatibility issues with an other program. Also, I have to use some .dll for my project (hardware). – arnaud13 Sep 11 '12 at 21:51

1 Answers1

0

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.

dutt
  • 7,909
  • 11
  • 52
  • 85