在linux上编译windows 64程序的问题 - 标题

时间:2014-01-05 05:26:53

标签: c++ linux gcc header

我一直在尝试在Linux上编译一个Windows 64程序,MSVAR1.3,并且遇到了Linux和程序调用的头文件的问题。该计划要求:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifdef __BORLANDC__
    #include <float.h>

如果我运行编译(在linux中使用gcc)并尝试使用-I标志来告诉它标题的位置,那么它比没有标题的情况下运行编译要好得多。我在下面列出了一些输出(我得到了近300行无法识别的变量)。

我也试过用数学库的-lm标志来运行它,这减少了无法识别的错误,但如果有其他标题库的标志,我就无法找到它们。请帮助!!!!

(使用-I标志运行时出错:)

gcc msvar1.3.c -o msvar1.3 -lm/tmp/ccpZIkC1.o: In function `main':
msvar1.3.c:(.text+0x38): undefined reference to `opengfsr'
msvar1.3.c:(.text+0x927): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x94c): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x971): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x9a2): undefined reference to `disrand'
msvar1.3.c:(.text+0x111a): undefined reference to `printerr'
msvar1.3.c:(.text+0x1809): undefined reference to `printerr'
msvar1.3.c:(.text+0x1ad2): undefined reference to `printerr'
msvar1.3.c:(.text+0x1be6): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x2773): undefined reference to `closegfsr'
msvar1.3.c:(.text+0x2791): undefined reference to `closegfsr'
/tmp/ccpZIkC1.o: In function `treesummary':
msvar1.3.c:(.text+0x2808): undefined reference to `printerr'
/tmp/ccpZIkC1.o: In function `read_params':
msvar1.3.c:(.text+0x2b1f): undefined reference to `printerr'
msvar1.3.c:(.text+0x2b64): undefined reference to `printerr'
msvar1.3.c:(.text+0x2b72): undefined reference to `intrand'
msvar1.3.c:(.text+0x2bb7): undefined reference to `printerr'
msvar1.3.c:(.text+0x3000): undefined reference to `printerr'
msvar1.3.c:(.text+0x3063): undefined reference to `printerr'
msvar1.3.c:(.text+0x3077): undefined reference to `printerr'
/tmp/ccpZIkC1.o: In function `choosepar':
msvar1.3.c:(.text+0x36fb): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x374b): undefined reference to `gfsr4'
msvar1.3.c:(.text+0x3799): undefined reference to `gfsr4'
msvar1.3.c:(.text+0x37b8): undefined reference to `norm4'
msvar1.3.c:(.text+0x37e5): undefined reference to `gfsr4'
msvar1.3.c:(.text+0x3826): undefined reference to `norm4'
msvar1.3.c:(.text+0x3853): undefined reference to `gfsr4'
msvar1.3.c:(.text+0x3894): undefined reference to `norm4'
msvar1.3.c:(.text+0x38f7): undefined reference to `norm4'

2 个答案:

答案 0 :(得分:2)

“未定义的引用”错误不是来自缺少的标题 - 它们是链接器错误,表明您没有链接到对象,也没有指定库的-l(减号)标志,导出这些符号。标题只构成一个承诺,即在链接时提供的对象/库中可以找到与标题声明相匹配的变量和行外函数 - 您正在破坏该承诺。

您需要找到包含这些符号的库,或找到源并编译它们。

答案 1 :(得分:0)

I compiled msvar1.3 with command:

gcc -o msvar1.3 myutil.c msvar1.3.c -lm