开发者

Other than header file what do you need to use the functions defined in header

I have a myheader.h file, i have included it successfully in my VC++ project, but i am not able to use any of it functions. It gives the error Unresolve开发者_如何学God external symbol (my function definition). What am i missing?

//Here is my code snippet
#include "myHeaders/myheader.h"
void main (){
    head_gen();
}

It doesnt build and the error is

Unresolved external symbol void__head_gen()

etc. Has it something to do with .lib file or something else?


You need the implementation of the function head_gen(). This can be in

  • a source file,
  • an object file or
  • a library

You should have one of them gotten with the header file.

If you have a .cpp file, add it to your project.

If you have a .obj or .lib file, add it as dependecy in the Project Properties:

Configuration Properties / Linker / Input -> Additional Dependencies

If the .obj or .lib file is in a different directory than your project, don't forget to add the path:

Configuration Properties / Linker / General -> Additional Library Directories


I develop mostly on Linux and use vi as an editor. But when I see such errors, it usually is one of the following reasons:

  1. The function head_gen() is defined under a namespace and the source code where head_gen() is used does not have the using namespace statement.
  2. Has head_gen() been defined in myHeader.cpp? That could be another reason why the function is not "visible".

HTH,
Sriram

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜