我的git 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我漏掉了什么明显的东西吗?
发布于 2016-04-17 03:53:01
我刚刚想明白了。我通过obj目录中的git输入了.o文件,gcc试图使用现有的文件(这些文件是在Cygwin +Windows中生成的)。不知怎么的,这些.o文件似乎与linux不兼容。当我删除它们并再次运行make命令时,将重新生成.o文件。我想故事的寓意是,GCC在Windows中生成的二进制文件和可执行文件与Linux不兼容(反之亦然)。
https://stackoverflow.com/questions/36672375
复制相似问题