开发者

Linker errors only when I make a function call to a recently added header file

So, I recently added a header file (and corresponding source file) to a project, along with a header file that file required, and an object file that the file required.

Everything compiles fine, unless I actually make a call to one of the functions declared in the newly added header file.

This is all using Visual Studio Express 2008.

To b开发者_开发百科e more clear: Added:

E4407B.h (My code)

E4407B.cpp (Also my code, compiling as c)

ni4882.h (not mine - from National Instruments) ni4882.obj

When I call a function located in E4407B.h, I get the following error:

4>E4407B.obj : error LNK2005: _SA_GPIB_INTF already defined in test.obj
4>ni4882.obj : warning LNK4217: locally defined symbol _fclose imported in function _LoadFunction@4
4>ni4882.obj : warning LNK4217: locally defined symbol _fread imported in function _LoadFunction@4
4>ni4882.obj : warning LNK4217: locally defined symbol _fopen imported in function _LoadFunction@4
4>ni4882.obj : error LNK2019: unresolved external symbol __imp__rand referenced in function _LoadFunction@4
4>ni4882.obj : error LNK2019: unresolved external symbol __imp__srand referenced in function _LoadFunction@4
4>ni4882.obj : error LNK2019: unresolved external symbol __imp__time referenced in function _LoadFunction@4

test.c is where main is located.

Edit: I had in an error that shows up for building another solution which was in the build for some reason.


It sounds like your header is defining objects (_SA_GPIB_INTF, _fclose, etc.) when it should only be declaring them. Any objects that require storage must only be defined in a single source file.

Also, the unresolved external symbol errors mean you're missing a library in the linking process (looks like the c standard library).

Without seeing the header code itself, it's hard to get any more specific.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜