Visual c ++未解析的extern符号错误 [英] Visual c++ Unresolved extern symbol error

查看:95
本文介绍了Visual c ++未解析的extern符号错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编译调用fitsio.h的源代码。来自fit库的文件,然后在fitsio.h中,另一个头文件名为longname.h,这个ffclos,ffgpxv all在longnam.h中定义。 。虽然我正在编译它的给出错误信息:


usimage.cpp

生成代码...

链接...

创建库.\Output / gci2.lib和object .\Output / gci2.exp

cam_simulator.obj:错误LNK2001:未解析的外部符号_ffclos

cam_simulator.obj:错误LNK2001:未解析的外部符号_ffgpxv

cam_simulator.obj:错误LNK2001:未解析的外部符号_ffthdu

cam_simulator.obj:错误LNK2001:未解析的外部符号_ffgisz

cam_simulator.obj:错误LNK2001:未解析的外部符号_ffgidm

cam_simulator.obj:错误LNK2001:未解析的外部符号_ffghdt

cam_simulator.obj:错误LNK2001:未解析的外部符号_ffdkopn

guide_routines.obj:错误LNK2001:未解析的外部符号" float __cdecl CalcSlope(类DoubleArray)" (?CalcSlope @@ YAMVDoubleArray @@@ Z)

。\\\ release / gci2.dll:致命错误LNK1120:8个未解析的外部

执行link.exe时出错。

PixCel.exe - 9个错误,3个警告

I am compiling my source code which is calling "fitsio.h" file from fits library , and then in fitsio.h another header file is getting called named longname.h , this ffclos , ffgpxv all are defined in "longnam.h" .While I am compiling its giving error message :

usimage.cpp
Generating Code...
Linking...
Creating library .\Output/gci2.lib and object .\Output/gci2.exp
cam_simulator.obj : error LNK2001: unresolved external symbol _ffclos
cam_simulator.obj : error LNK2001: unresolved external symbol _ffgpxv
cam_simulator.obj : error LNK2001: unresolved external symbol _ffthdu
cam_simulator.obj : error LNK2001: unresolved external symbol _ffgisz
cam_simulator.obj : error LNK2001: unresolved external symbol _ffgidm
cam_simulator.obj : error LNK2001: unresolved external symbol _ffghdt
cam_simulator.obj : error LNK2001: unresolved external symbol _ffdkopn
guide_routines.obj : error LNK2001: unresolved external symbol "float __cdecl CalcSlope(class DoubleArray)" (?CalcSlope@@YAMVDoubleArray@@@Z)
.\Release/gci2.dll : fatal error LNK1120: 8 unresolved externals
Error executing link.exe.
PixCel.exe - 9 error(s), 3 warning(s)

推荐答案

当你在编译链接时是链接器错误。


函数ffclos等没有在longnam.h中定义(至少我怀疑它们是)在longnam.h中声明它们。

编译器只需要声明,告诉它函数存在于某处,使用它们编译文件。但链接器确实需要定义才能构建使用这些函数的程序。


通常,第三方函数的定义将存在于库文件中(.lib )虽然声明存在于标题(.h)中。


导致此错误的最可能原因是您已经失败/忘记将所需的库添加到链接中。 />

在项目属性中查找链接器选项。
Not while you are compiling, while you are linking those are linker errors.

The functions ffclos etc are not defined in longnam.h (at least I doubt they are) they are declared in longnam.h.

The compiler only needs the declarations, which tell it that the function exists somewhere, to compile a file using them. however the linker does need the definitions in order to be able to build a program that uses the functions.

Normally the definitions for a 3rd party function will exist in the library file (.lib) while the declarations exist in the header (.h).

The most likely cause for this error is that you have failed/forgotten to add the required library to the link.

Look for linker options in your project properties.


@Banfa


非常感谢你清理我的概念,这里发生了什么,它完成了检查所有文件,所以我认为它在编译期间没有找到错误。然后当它与库链接


链接...

创建库。\ Output / gci2.lib和object。\ Output / gci2.exp

cam_simulator.obj:错误LNK2001:未解析的外部符号_ffclos

cam_simulator.obj:错误LNK2001:未解析的外部符号_ffgpxv

" ;


它产生错误,我在项目链接器属性中正确链接..是否需要任何其他设置或链接?
@Banfa
thank you very much for clearing my concepts , here what happening , its completing checking all the file , so i think it doesnt find an error during compilation . Then when it is linking with library

"Linking...
Creating library .\Output/gci2.lib and object .\Output/gci2.exp
cam_simulator.obj : error LNK2001: unresolved external symbol _ffclos
cam_simulator.obj : error LNK2001: unresolved external symbol _ffgpxv
"

its generating the error , i have linked properly in my project linker property ..Is it require any other setting or linking ?


是有一些库(.lib)或源文件(.c)与longnam.h一起需要包含在项目中。
Yes there is some library (.lib) or source file (.c) that goes along with longnam.h and needs including into the project.


这篇关于Visual c ++未解析的extern符号错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆