Ошибка LNK2019 при построении решения

Я пытаюсь скомпилировать пример кода, используя библиотеки OpenHaptics в Visual Syudio 2010. Я связал многопоточную среду выполнения C и библиотеки через Project Properties -> Linker -> Input. И включил каталоги, а также. Файл .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

Возможно ли, что библиотеки предназначены для работы в 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;
}    

person Victor Arnez    schedule 15.04.2011    source источник
comment
Хорошо, я попытался запустить его в Windows XP, и это помогло, но не так сильно, появляется эта новая ошибка: hdu.lib(hduError.obj): ошибка LNK2019: неразрешенный внешний символ _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), на которые ссылается класс функций 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   -  person Victor Arnez    schedule 18.04.2011


Ответы (1)


У меня также возникла эта проблема с запуском файлов примеров в Visual C++ Express 2010. Я установил Visual C++ 2008 Express Edition, и примеры, кажется, компилируются. За исключением того, что вам нужно создавать код выпуска, а не отлаживать. Не совсем решение, но, похоже, работает.

person Tim Brooke    schedule 19.08.2011
comment
Хотел сказать, что я делаю все это в Windows 7. - person Tim Brooke; 19.08.2011
comment
Спасибо, Тим. Углубившись в ошибку, я обнаружил, что учебник OpenHaptics не был полным с точки зрения библиотек, и для правильной работы проекта необходимо было связать некоторые дополнительные библиотеки. Однако некоторые из заголовков в руководстве не были полностью совместимы с программным обеспечением, которое я использовал (MVS Express 2010 в Windows 7), но в конце концов я смог не использовать методы, которым требовались эти конкретные заголовки. Лаки Я. - person Victor Arnez; 01.09.2011