Visual c++ 构建解决方案时出现LNK2019错误

Visual c++ 构建解决方案时出现LNK2019错误,visual-c++,linker-errors,lnk2019,Visual C++,Linker Errors,Lnk2019,我正在尝试使用Visual Syudio 2010中的OpenHaptics库编译一个示例代码。我通过projectproperties->Linker->Input链接了多线程C-runtime和库。还包括目录。file.dll位于系统文件中。但当我尝试构建时,同样的错误会出现 Haptics.obj : error LNK2019: unresolved external symbol __imp__hlEndFrame@0 referenced in function "void __cd

我正在尝试使用Visual Syudio 2010中的OpenHaptics库编译一个示例代码。我通过
projectproperties->Linker->Input
链接了多线程C-runtime和库。还包括目录。file.dll位于系统文件中。但当我尝试构建时,同样的错误会出现

Haptics.obj : error LNK2019: unresolved external symbol __imp__hlEndFrame@0 referenced in function "void __cdecl display(void)" (?display@@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)" (__imp_?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z) 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 *)" (??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)
MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
Haptics.obj:错误LNK2019:未解析的外部符号\uuu imp__hlEndFrame@0在函数“void\uu cdecl display(void)”中引用(?display@@YAXXZ)

hdu.lib(hduError.obj):错误LNK2019:未解析的外部符号“\uu declspec(dllimport)public:int\uu thiscall std::basic\u streambuf::sputn(char const*,int)”(\uu imp\uu?sputn@$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z)在函数中引用“类STD::Basic ToSoSoo.SytCCDL STD::运算符< P>,我也在VisualC++快照2010中运行示例文件时遇到这个问题。 我安装了Visual C++ 2008 Express版,并举例编译。 除非您必须创建发布代码而不是调试。
这不是一个真正的解决方案,但它似乎有效。

好的,我尝试在Windows XP上运行它,它起到了帮助作用,但没有那么大,出现了一个新错误:hdu.lib(hduError.obj):错误LNK2019:未解析的外部符号“\u declspec(dlliport)public:int\u thiscall std::basic\u streambuf::sputn(char const*,int)”(uu imp?sputn@?$basic)_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z)在函数中引用"class std::basic_ostream&u cdecl std::operatorMant我要说的是,我在Windows 7中完成了所有这些。谢谢Tim。深入研究错误后,我发现OpenHaptics教程在库方面并不完整,需要将一些额外的库链接到该项目才能正常运行。但是,一些教程中的ER与我使用的软件(Windows7上的MVS Express 2010)不完全兼容,但最终我无法使用需要这些特定头的方法。
#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;
}