简体   繁体   English

makefile在windows上使用cygwin,但不适用于ubuntu

[英]makefile works with cygwin on windows but not ubuntu

I have the following folder on my git repo - https://github.com/ryu577/base/tree/master/numerical/c/NumericalRecipiesCode/lib 我的git repo上有以下文件夹 - https://github.com/ryu577/base/tree/master/numerical/c/NumericalRecipiesCode/lib

On my windows machine which has cygwin installed, I can run make in that directory, which triggers the command - 在安装了cygwin的Windows机器上,我可以在该目录中运行make,这会触发命令 -

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

This puts the tst_libfns.o and fileio.o in the obj directory. 这将tst_libfns.o和fileio.o放在obj目录中。

Now, I pulled this repository into my ubuntu machine and tried the same thing. 现在,我将这个存储库拉到了我的ubuntu机器上并尝试了同样的事情。 However, when the same command is generated there, it gives me the following error: 但是,当在那里生成相同的命令时,它会给我以下错误:

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

Am I missing something obvious? 我错过了一些明显的东西吗

I just figured it out. 我刚想通了。 I had pulled in the .o files through git in the obj directory and gcc was somehow trying to use the existing files (which had been generated in Cygwin + Windows). 我通过obj目录中的git引入.o文件,gcc试图使用现有文件(已在Cygwin + Windows中生成)。 Somehow, those .o files don't seem to be compatible with linux. 不知何故,那些.o文件似乎与linux不兼容。 When I delete them and run the make command again, the .o files are re-generated. 当我删除它们并再次运行make命令时,将重新生成.o文件。 I guess the moral of the story here is that binaries and executables generated by GCC in Windows are incompatible with Linux (and I'll guess vice versa). 我想这里故事的寓意是,GCC在Windows中生成的二进制文件和可执行文件与Linux不兼容(反之亦然)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM