2011-04-15 3 views
0

Je suis en train de compiler un exemple de code à l'aide de bibliothèques OpenHaptics dans Visual Syudio 2010. J'ai lié le C-runtime multithread et les bibliothèques via Project Properties -> Linker -> Input. Et inclus les répertoires aussi bien. Le fichier.dll est dans le fichier système. Mais quand j'essaie de construire les mêmes erreurs viennent.erreur LNK2019 lors de la construction de la solution

Haptics.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl display(void)" ([email protected]@YAXXZ) 
hdu.lib(hduError.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" ([email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@@[email protected]@[email protected]) 
MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol [email protected] referenced in function ___tmainCRTStartup 

Est-il possible que les bibliothèques soient conçues pour fonctionner sous Windows XP et non sous Windows 7? Ou y a-t-il autre chose qui me manque? Je suis nouveau à C. Toute aide serait grandement appréciée.

#include <stdio.h> 
#include <stdlib.h> 

#if defined(WIN32) 
# include <windows.h> 
#endif 

#if defined(WIN32) || defined(linux) 
# include <GL/glut.h> 
#elif defined(__APPLE__) 
# include <GLUT/glut.h> 
#endif 

// Header files for OpenHaptics. 
#include <HL/hl.h> 
#include <HDU/hduError.h> 

// id needed for haptic shape. 
HLuint gMyShapeId; 

void display(void) 
{ 
    // Start a haptic frame. 
    hlBeginFrame(); 

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
glColor3f(1.0, 1.0, 1.0); 

// Start the haptic shape. 
hlBeginShape(HL_SHAPE_DEPTH_BUFFER, gMyShapeId); 
glBegin(GL_POLYGON); 
glVertex3f(0.25, 0.25, 0.0); 
glVertex3f(0.75, 0.25, 0.0); 
glVertex3f(0.75, 0.75, 0.0); 
glVertex3f(0.25, 0.75, 0.0); 
glEnd(); 

// End the haptic shape. 
hlEndShape(); 

// End the haptic frame. 
hlEndFrame(); 
} 

void init(void) 
{ 
    glClearColor(0.0, 0.0, 0.0, 0.0); 
    glMatrixMode(GL_PROJECTION); 
    glLoadIdentity(); 
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); 

// Enable depth buffering to provide depth information for OpenHaptics. 
glDepthFunc(GL_LEQUAL); 
glEnable(GL_DEPTH_TEST); 

// OpenHaptics setup follows: 

// Create a haptic device instance. 
HDErrorInfo error; 
HHD hHD = hdInitDevice(HD_DEFAULT_DEVICE); 
if (HD_DEVICE_ERROR(error = hdGetError())) 
{ 
    hduPrintError(stderr, &error, "Failed to initialize haptic device"); 
    fprintf(stderr, "Press any key to exit"); 
    getchar(); 
    exit(-1); 
} 

if (HD_SUCCESS != hdGetError().errorCode) 
{ 
    fprintf(stderr, "Erorr initializing haptic device.\nPress any key to exit"); 
    getchar(); 
    exit(-1); 
} 

// Create a haptic rendering context and activate it. 
HHLRC hHLRC = hlCreateContext(hHD); 
hlMakeCurrent(hHLRC); 

// Reserve an id for the shape 
gMyShapeId = hlGenShapes(1); 

// Specify the boundaries for the workspace of the haptic device 
// in millimeters in the cordinates of the haptic device. 
// The haptics engine will map the view volume to this workspace 
hlWorkspace (-80, -80, -70, 80, 80, 20); 

// Specify the haptic view volume (in this case it will be 
// the same as the graphic view volume). 
hlMatrixMode(HL_TOUCHWORKSPACE); 
hlLoadIdentity(); 
hlOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0); 
} 

void glutMenu(int ID) 
{ 
    switch(ID) { 
     case 0: 
      exit(0); 
      break; 
    } 
} 

int main(int argc, char** argv) 
{ 
    glutInit(&argc, argv); 
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); 
    glutInitWindowSize(250, 250); 
    glutInitWindowPosition(100, 100); 
    glutCreateWindow("Hello Haptics"); 
    glutCreateMenu(glutMenu); 
    glutAddMenuEntry("Quit", 0); 
    glutAttachMenu(GLUT_RIGHT_BUTTON); 
    init(); 
    glutDisplayFunc(display); 
    glutMainLoop(); 
    return 0; 
}  
+0

Ok, j'ai essayé de l'exécuter sur Windows XP et il a aidé, mais pas beaucoup, cette nouvelle erreur est comming jusqu'à: hdu.lib (hduError.obj): erreur LNK2019: symbole externe non résolu « __declspec (dllimport) public: int __thiscall std :: base_streambuf > :: sputn (char const *, int) "(__imp_? sputn @? $ basic_streambuf @ DU? $ char_traits @ D @ std @@@ std @@ QAEHPBDH @ Z) référencé dans la fonction "classe std :: basic_ostream > & __cdecl std :: opérateur <<< structure std :: char_traits > (classe std :: basic_ostream > &, char const –

Répondre

1

Je suis aussi avoir ce problème les fichiers en cours d'exécution par exemple dans Visual C++ express 2010. J'ai installé Visual C++ 2008 Express Edition et les exemples semble compiler. Sauf que vous devez créer un code de version non débogué. Pas vraiment une solution mais cela semble fonctionner.

+0

Pour dire que je fais tout cela dans Windows 7. –

+0

Merci Tim. Travailler plus profond dans l'erreur, j'ai découvert que le didacticiel OpenHaptics n'était pas complet en termes de bibliothèques, et certaines bibliothèques supplémentaires étaient nécessaires pour être liées au projet afin de l'exécuter correctement. Cependant, certains des en-têtes du didacticiel n'étaient pas entièrement compatibles avec le logiciel que j'utilisais (MVS Express 2010 sous Windows 7), mais à la fin, je ne pouvais pas utiliser les méthodes qui nécessitaient ces en-têtes. Lucky I. –

Questions connexes