我想在Visual Syudio 2010中使用OpenHaptics庫編譯示例代碼。我通過Project Properties -> Linker -> Input
將多線程C運行庫和庫鏈接起來。幷包括目錄。 file.dll在系統文件中。但是當我嘗試構建相同的錯誤時。LNK2019構建解決方案時出錯
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
這是可能的圖書館的目的是運行在Windows XP中,而不是在Windows 7中?還是有什麼我失蹤?我是新來的C.任何幫助將不勝感激。
#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;
}
好吧,我試圖在Windows XP上運行它,它幫助,但不是很多,這個新的錯誤了正在添加: hdu.lib(hduError.obj):錯誤LNK2019:無法解析的外部符號「__declspec(dllimport的)public:int __thiscall std :: basic_streambuf> :: sputn(char const *,int)「(__imp_?sputn @?$ basic_streambuf @ DU?$ char_traits @ D @ std @@@ std :: base_ostream >&__cdecl std :: operator <<< struct std :: char_traits >(class std :: basic_ostream >&,char const –
2011-04-18 15:59:10