开发者

Error in Visual Studio

I get this error in visual studio and I don't know the reason. It doesn't even show the line number. Any clue?

Error 1 error LNK2028: unresolved token (0A000041) "void __cdecl free_img(struct Image *)" (?free_img@@$$FYAXPAUImage@@@Z) referenced in function "double * __cdecl calc_zernike_moments(struct Image const *,int,struct ZernikeBasis const *)" (?calc_zernike_开发者_如何转开发moments@@$$FYAPANPBUImage@@HPBUZernikeBasis@@@Z) zernike_moments.obj TestLibrary


You have a routine

double * __cdecl calc_zernike_moments(struct Image const *foo,
                                      int baz,
                                      struct ZernikeBasis const *bar)

that calls a routine

void __cdecl free_img(struct Image *foo)

and you didn't supply the free_img() routine that matched to the linker.


free_img() is a function that is either defined in a .cpp file that you haven't included in the project, or it is in a DLL or static library that you haven't linked against. If it is the former, you need to search for the function in your source files and then add that .cpp file to the project. If it is the latter, then you need to identify which library provides free_img() and then locate the .lib file for that library. Then you can do this:

To add .lib files as linker input in the development environment

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
  2. Click the Linker folder.
  3. Click the Input property page.
  4. Modify the Additional Dependencies property. (from http://msdn.microsoft.com/en-us/library/ba1z7822(VS.80).aspx)


You need to link the library. Where is the definition of free_img()? You are just including the .h and not linking lib


The error is a linker error, not a compiler error, so there won't be a line number associated with it. Rather the error is telling you that your function calc_zernike_moments is calling another routine, free_img, that isn't defined in any of TestLibrary's compiled sources, so you need to provide it by other means. Typically what's missing here is the third-party library need be included in the project so the linker can bring in free_img's implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜