2 qq 25107617 qq_25107617 于 2016.04.15 12:12 提问

ARToolkit在VS2010配置问题,链接时 LNK2019错误 (未解决) 50C

#include "stdafx.h"
#ifdef WIN32
#include
#endif
#include
#include
#ifndef __APPLE
_
#include
#define GLUT_DISABLE_ATEXIT_HACK

#include
#endif
#include
#include
#include
#include

//
// Camera configuration.
//
#ifdef _WIN32
char *vconf = "Data\WDM_camera_flipV.xml";
#else
char *vconf = "";
#endif

int xsize, ysize;
int thresh = 100;
int count = 0;

char *cparam_name = "Data/camera_para.dat";
ARParam cparam;

char *patt_name = "Data/patt.hiro";
int patt_id;
double patt_width = 80.0;
double patt_center[2] = {0.0, 0.0};
double patt_trans[3][4];

static void init(void);
static void cleanup(void);
static void keyEvent( unsigned char key, int x, int y);
static void mainLoop(void);
static void draw( void );

int main(int argc, char **argv)
{
glutInit(&argc, argv);
init();

arVideoCapStart();
argMainLoop( NULL, keyEvent, mainLoop );
return (0);

}

static void keyEvent( unsigned char key, int x, int y)
{
/* quit if the ESC key is pressed /
if( key == 0x1b ) {
printf("
** %f (frame/sec)\n", (double)count/arUtilTimer());
cleanup();
exit(0);
}
}

/* main loop */
static void mainLoop(void)
{
ARUint8 *dataPtr;
ARMarkerInfo *marker_info;
int marker_num;
int j, k;

/* grab a vide frame */
if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) {
    arUtilSleep(2);
    return;
}
if( count == 0 ) arUtilTimerReset();
count++;

argDrawMode2D();
argDispImage( dataPtr, 0,0 );

/* detect the markers in the video frame */
if( arDetectMarker(dataPtr, thresh, &marker_info, &marker_num) < 0 ) {
    cleanup();
    exit(0);
}

arVideoCapNext();

/* check for object visibility */
k = -1;
for( j = 0; j < marker_num; j++ ) {
    if( patt_id == marker_info[j].id ) {
        if( k == -1 ) k = j;
        else if( marker_info[k].cf < marker_info[j].cf ) k = j;
    }
}
if( k == -1 ) {
    argSwapBuffers();
    return;
}

/* get the transformation between the marker and the real camera */
arGetTransMat(&marker_info[k], patt_center, patt_width, patt_trans);

draw();

argSwapBuffers();

}

static void init( void )
{
ARParam wparam;

/* open the video path */
if( arVideoOpen( vconf ) < 0 ) exit(0);
/* find the size of the window */
if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);

/* set the initial camera parameters */
if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
    printf("Camera parameter load error !!\n");
    exit(0);
}
arParamChangeSize( &wparam, xsize, ysize, &cparam );
arInitCparam( &cparam );
printf("*** Camera Parameter ***\n");
arParamDisp( &cparam );

if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
    printf("pattern load error !!\n");
    exit(0);
}

/* open the graphics window */
argInit( &cparam, 1.0, 0, 0, 0, 0 );

}

/* cleanup function called when program exits */
static void cleanup(void)
{
arVideoCapStop();
arVideoClose();
argCleanup();
}

static void draw( void )
{
double gl_para[16];
GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash_shiny[] = {50.0};
GLfloat light_position[] = {100.0,-200.0,200.0,0.0};
GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};

argDrawMode3D();
argDraw3dCamera( 0, 0 );
glClearDepth( 1.0 );
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

/* load the camera transformation matrix */
argConvGlpara(patt_trans, gl_para);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd( gl_para );

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);  
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMatrixMode(GL_MODELVIEW);
glTranslatef( 0.0, 0.0, 25.0 );
glutSolidCube(50.0);
glDisable( GL_LIGHTING );

glDisable( GL_DEPTH_TEST );

}

1>ClCompile:
1> stdafx.cpp
1> ARFirstApplication.cpp
1>libARgsubd.lib(gsub.obj) : error LNK2019: 无法解析的外部符号 ___glutCreateWindowWithExit@8,该符号在函数 _glutCreateWindow_ATEXIT_HACK@4 中被引用
1>C:\Users\Yang\Documents\Visual Studio 2010\Projects\ARFirstApplication\Debug\ARFirstApplication.exe : fatal error LNK1120: 1 个无法解析的外部命令
1>
1>生成失败。
1>
1>已用时间 00:00:01.83
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

3个回答

zanfeng
zanfeng   2016.04.17 12:47

检查头文件包含是否正确,lib库是否包含的正确。其他的没有啥了。

qq_25107617
qq_25107617 第一次用,我把图发在楼下,麻烦看看对不对
一年多之前 回复
qq_25107617
qq_25107617   2016.04.18 12:11

图片说明
图片说明
附加依赖项:libARd.lib
libARvideod.lib
libARgsubd.lib
libARgsub_lited.lib
libARgsubUtild.lib
libARvrmld.lib
libARMultid.lib
Opengl32.lib
opengl.lib
glu.lib
Glu32.lib
glut.lib
glut32.lib
GLAUX.LIB
libAR.lib
libARgsub_lite.lib
libARgsubUtil.lib
libARMulti.lib
libARvideo.lib
libARvrml.lib
我把lib文件里的都写上去了

zanfeng
zanfeng   2016.04.18 12:25

你直接COPY到debug目录

sym60123
sym60123 回复qq_25107617: 解决了吗?我也是卡在这了
一年多之前 回复
qq_25107617
qq_25107617 能详细点吗,谢谢。 或者能加我Q Q 515546341详细说吗? 万分感谢
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!