紧急求救:在编译SIFT相关识别程序时出现7条“error LNK2019: 无法解析的外部符号”

dunzi0111 2012-01-11 09:59:55
小弟是C++新手,在编译如下SIFT识别程序的时候遇到一下的情况,希望大家能帮帮忙,解一下燃眉之急,不甚感激!!

#include "stdafx.h"
#include "sift.h"
#include "imgfeatures.h"
#include "kdtree.h"
#include "utils.h"
#include "xform.h"

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

#include <stdio.h>


/* the maximum number of keypoint NN candidates to check during BBF search */
#define KDTREE_BBF_MAX_NN_CHKS 200

/* threshold on squared ratio of distances between NN and 2nd NN */
#define NN_SQ_DIST_RATIO_THR 0.49

/******************************** Globals ************************************/

char img1_file[] = "..\\beaver.png";
char img2_file[] = "..\\beaver_xform.png";

/********************************** Main *************************************/


int main( int argc, char** argv )
{
IplImage* img1, * img2, * stacked;
struct feature* feat1, * feat2, * feat;
struct feature** nbrs;
struct kd_node* kd_root;
CvPoint pt1, pt2;
double d0, d1;
int n1, n2, k, i, m = 0;

img1 = cvLoadImage( img1_file, 1 );
if( ! img1 )
fatal_error( "unable to load image from %s", img1_file );
img2 = cvLoadImage( img2_file, 1 );
if( ! img2 )
fatal_error( "unable to load image from %s", img2_file );
stacked = stack_imgs( img1, img2 );

fprintf( stderr, "Finding features in %s...\n", img1_file );
n1 = sift_features( img1, &feat1 );
fprintf( stderr, "Finding features in %s...\n", img2_file );
n2 = sift_features( img2, &feat2 );
kd_root = kdtree_build( feat2, n2 );
for( i = 0; i < n1; i++ )
{
feat = feat1 + i;
k = kdtree_bbf_knn( kd_root, feat, 2, &nbrs, KDTREE_BBF_MAX_NN_CHKS );
if( k == 2 )
{
d0 = descr_dist_sq( feat, nbrs[0] );
d1 = descr_dist_sq( feat, nbrs[1] );
if( d0 < d1 * NN_SQ_DIST_RATIO_THR )
{
pt1 = cvPoint( cvRound( feat->x ), cvRound( feat->y ) );
pt2 = cvPoint( cvRound( nbrs[0]->x ), cvRound( nbrs[0]->y ) );
pt2.y += img1->height;
cvLine( stacked, pt1, pt2, CV_RGB(255,0,255), 1, 8, 0 );
m++;
feat1[i].fwd_match = nbrs[0];
}
}
free( nbrs );
}

fprintf( stderr, "Found %d total matches\n", m );
cvNamedWindow( "Matches", 1 );
cvShowImage( "Matches", stacked );
cvWaitKey( 0 );


/*
UNCOMMENT BELOW TO SEE HOW RANSAC FUNCTION WORKS

Note that this line above:

feat1[i].fwd_match = nbrs[0];

is important for the RANSAC function to work.
*/
/*
{
CvMat* H;
H = ransac_xform( feat1, n1, FEATURE_FWD_MATCH, lsq_homog, 4, 0.01,
homog_xfer_err, 3.0, NULL, NULL );
if( H )
{
IplImage* xformed;
xformed = cvCreateImage( cvGetSize( img2 ), IPL_DEPTH_8U, 3 );
cvWarpPerspective( img1, xformed, H,
CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS,
cvScalarAll( 0 ) );
cvNamedWindow( "Xformed", 1 );
cvShowImage( "Xformed", xformed );
cvWaitKey( 0 );
cvReleaseImage( &xformed );
cvReleaseMat( &H );
}
}
*/

cvReleaseImage( &stacked );
cvReleaseImage( &img1 );
cvReleaseImage( &img2 );
kdtree_release( kd_root );
free( feat1 );
free( feat2 );
return 0;
}
1>------ 已启动生成: 项目: picturecopy1, 配置: Debug Win32 ------
1> picturecopy1.cpp
1>c:\program files\opencv2.3\build\include\opencv2\flann\logger.h(70): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : 参见“fopen”的声明
1>picturecopy1.obj : error LNK2019: 无法解析的外部符号 "void __cdecl kdtree_release(struct kd_node *)" (?kdtree_release@@YAXPAUkd_node@@@Z),该符号在函数 _main 中被引用
1>picturecopy1.obj : error LNK2019: 无法解析的外部符号 "double __cdecl descr_dist_sq(struct feature *,struct feature *)" (?descr_dist_sq@@YANPAUfeature@@0@Z),该符号在函数 _main 中被引用
1>picturecopy1.obj : error LNK2019: 无法解析的外部符号 "int __cdecl kdtree_bbf_knn(struct kd_node *,struct feature *,int,struct feature * * *,int)" (?kdtree_bbf_knn@@YAHPAUkd_node@@PAUfeature@@HPAPAPAU2@H@Z),该符号在函数 _main 中被引用
1>picturecopy1.obj : error LNK2019: 无法解析的外部符号 "struct kd_node * __cdecl kdtree_build(struct feature *,int)" (?kdtree_build@@YAPAUkd_node@@PAUfeature@@H@Z),该符号在函数 _main 中被引用
1>picturecopy1.obj : error LNK2019: 无法解析的外部符号 "int __cdecl sift_features(struct _IplImage *,struct feature * *)" (?sift_features@@YAHPAU_IplImage@@PAPAUfeature@@@Z),该符号在函数 _main 中被引用
1>picturecopy1.obj : error LNK2019: 无法解析的外部符号 "struct _IplImage * __cdecl stack_imgs(struct _IplImage *,struct _IplImage *)" (?stack_imgs@@YAPAU_IplImage@@PAU1@0@Z),该符号在函数 _main 中被引用
1>picturecopy1.obj : error LNK2019: 无法解析的外部符号 "void __cdecl fatal_error(char *,...)" (?fatal_error@@YAXPADZZ),该符号在函数 _main 中被引用
1>C:\Users\acer\documents\visual studio 2010\Projects\picturecopy1\Debug\picturecopy1.exe : fatal error LNK1120: 7 个无法解析的外部命令
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
...全文
1102 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
原来未知 2014-04-18
  • 打赏
  • 举报
回复
楼主,请问如何改的,我在VS2010里面也出现了这个问题,我不知该如何改了
lanhongyun1201 2012-05-03
  • 打赏
  • 举报
回复
请问是将哪几个改了呢,O(∩_∩)O谢谢
oncall 2012-04-27
  • 打赏
  • 举报
回复
请问楼主是把哪个改的呢,我也遇到这个问题了,谢谢!
tanjinjun 2012-01-12
  • 打赏
  • 举报
回复
lib文件没有加进来,头文件中包含了那些函数,但是没有加lib文件
dunzi0111 2012-01-12
  • 打赏
  • 举报
回复
谢谢1、2、3楼,我整明白了,把#include其中的几个.h改成.cpp调试后就可以了。
quwei197874 2012-01-12
  • 打赏
  • 举报
回复
缺少什么库
薛定谔之死猫 2012-01-11
  • 打赏
  • 举报
回复
没有用过这个东东,不过连接器报的貌似是没加dll的lib映射文件,或者有编译单元没被加到工程中来~

5,530

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 模式及实现
社区管理员
  • 模式及实现社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧