【发布时间】:2019-06-27 11:31:04
【问题描述】:
我已成功使用f2c.exe 将一些 Fortran *.f 文件转换为 *.c 文件。我确保每个 C 文件中都有 #include "f2c.h" exists,并在 MS VS2008 中添加了包含该头文件的目录:Properties -> C/C++ -> General -> Additional Include Directories
问题开始于源文件中存在的所有 f2c IO 和数学函数报告的未解决的外部符号错误:
s_rsue, e_rsue, s_rsfe, do_uio, f_close, do_fio, do_lio, f_open, s_stop, pow, pow_ri, sqrt, log, exp, tanh, cos, acos等
我读到here 必须先由downloading libf2c 生成静态库文件vcf2c.lib。所以我使用nmake in VS2008 运行makefile.vc 并生成vcf2c.lib,然后我将其复制到我的项目目录并添加到Configuration Properties -> Linker -> Input -> Additional Dependencies 下,但我仍然得到与以前相同的未解析的外部符号。
我是否正确构建了这个库,以便 Visual Studio 能够识别其中的函数?我在这里想念什么?添加这个库似乎有零效果。感谢您的帮助。
错误示例:
error LNK2019: unresolved external symbol "long __cdecl e_rsue(void)" (?e_rsue@@YAJXZ) referenced in function _main
error LNK2019: unresolved external symbol "long __cdecl do_uio(long *,char *,long)" (?do_uio@@YAJPAJPADJ@Z) referenced in function _main
error LNK2019: unresolved external symbol "long __cdecl s_rsue(struct cilist *)" (?s_rsue@@YAJPAUcilist@@@Z) referenced in function _main
error LNK2019: unresolved external symbol "double __cdecl log(double)" (?log@@YANN@Z) referenced in function _main
error LNK2019: unresolved external symbol "double __cdecl sqrt(double)" (?sqrt@@YANN@Z) referenced in function "int __cdecl calcfl_(void)" (?calcfl_@@YAHXZ)
error LNK2019: unresolved external symbol "double __cdecl cos(double)" (?cos@@YANN@Z) referenced in function "int __cdecl waveno_(float *,float *)" (?waveno_@@YAHPAM0@Z)
编辑:我一直在尝试诊断库文件本身的任何问题。我什至尝试下载version that was compiled by someone else,但仍然无法解决外部问题。以下是运行 dumpbin 的结果:
dumpbin /exports vcf2c.lib
Dump of file vcf2c.lib
File Type: LIBRARY
Summary
18A0 .bss
246 .data
1110 .debug$F
513C .debug$S
1C17 .drectve
B73 .rdata
A5BD .text
我不知道这意味着什么。当我使用 /ALL 标志运行它时,我可以在其中看到所需的函数名称,但同样,我不确定如何确定它是否正确。源代码函数和库函数之间是否存在某种不匹配? 16 位与 32 位、C 与 C++ 生成文件选项?
【问题讨论】:
-
在这里遇到同样的问题!但令人惊讶的是,我可以编译 64 位版本但不能编译 32 位版本..
标签: c++ visual-studio-2008 makefile static-libraries f2c