c-makefile可以在windows上使用cygwin,但不能在ubuntu上使用



我的git repo上有以下文件夹-https://github.com/ryu577/base/tree/master/numerical/c/NumericalRecipiesCode/lib

在安装了cygwin的windows机器上,我可以在该目录中运行make,它会触发命令-

gcc -o ../bin/lib/tst_libfns ../obj/nrutil.o ../obj/fileio.o ../obj/tst_libfns.o -I ../include -lm

这将tst_libfns.o和fileio.o放在obj目录中。

现在,我把这个存储库拉到我的ubuntu机器上,并尝试了同样的事情。然而,当在那里生成相同的命令时,它会给我以下错误:

gcc -o ../bin/lib/tst_libfns ../obj/nrutil.o ../obj/fileio.o ../obj/tst_libfns.o -I../include -lm
../obj/fileio.o:fileio.c:(.text+0x52): undefined reference to `__getreent'
../obj/tst_libfns.o:tst_libfns.c:(.text+0x10): undefined reference to `__main'
collect2: error: ld returned 1 exit status
make: *** [../bin/lib/tst_libfns] Error 1

我是不是错过了一些显而易见的东西?

我刚刚想明白了。我已经通过git在obj目录中拉入了.o文件,而gcc不知何故试图使用现有的文件(这些文件是在Cygwin+Windows中生成的)。不知怎么的,那些.o文件似乎与linux不兼容。当我删除它们并再次运行make命令时,会重新生成.o文件。我想这个故事的寓意是GCC在Windows中生成的二进制文件和可执行文件与Linux不兼容(我想反之亦然)。

相关内容

最新更新