简体   繁体   English

在Cygwin中编译linux C程序时遇到问题

[英]Trouble compiling linux C program in cygwin

I'm trying to compile a program called minimodem for linux in Cygwin, because I want to be able to run it in windows. 我试图在Cygwin中为Linux编译一个名为minimodem的程序,因为我希望能够在Windows中运行它。 It's a simple command line program, and I installed Cygwin with basically all of the required libraries to compile it. 这是一个简单的命令行程序,我安装了Cygwin,基本上使用了所有必需的库来进行编译。

Some of the libraries are: All the audio, video, math, compile, develop, api, and system and base are installed. 其中的一些库是:已安装所有音频,视频,数学,编译,开发,api以及系统和基础。

One of the first problems I ran into was ./configure. 我遇到的第一个问题是./configure。 From the source code of the project in github, there is no configure file or folder. 从github中项目的源代码来看,没有配置文件或文件夹。 I decided to ditch that and instead use make directly instead and reference all the files in the folder. 我决定放弃它,而是直接使用make并引用该文件夹中的所有文件。

First what happened is I got this error: 首先发生的事情是我得到了这个错误:

minimodem.c: In function 'main': minimodem.c:556:4: error: #error At least one of {USE_PULSEAUDIO,USE_ALSA,USE_SNDFILE} must be enabled! minimodem.c:在函数“ main”中:minimodem.c:556:4:错误:#error必须启用{USE_PULSEAUDIO,USE_ALSA,USE_SNDFILE}中的至少一个! # error At least one of {USE_PULSEAUDIO,USE_ALSA,USE_SNDFILE} must be enabled! #错误必须启用{USE_PULSEAUDIO,USE_ALSA,USE_SNDFILE}中的至少一个! ^~~~~ ^ ~~~~

so I went into the code and removed the part that checks the audio driver(even though Cygwin has all the audio libraries available) and I tried it again: 因此,我进入代码并删除了检查音频驱动程序的部分(即使Cygwin有可用的所有音频库),然后我再次尝试了它:

gcc -o minimodem.c gcc -o minimodem.c

Then the compiler got a bit farther and then gave this error: 然后编译器走得更远,然后出现此错误:

/tmp/cc5sSG5R.o: In function `fsk_transmit_frame':
/home/8bit_coder/minimodem-master/src/minimodem.c:95: undefined reference to `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:95:(.text+0xb9): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:106: undefined reference to `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:106:(.text+0xf2): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `simpleaudio_tone'
/tmp/cc5sSG5R.o: In function `tx_stop_transmit_sighandler':
/home/8bit_coder/minimodem-master/src/minimodem.c:65: undefined reference to `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:65:(.text+0x27f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:68: undefined reference to `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:68:(.text+0x2ec): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `simpleaudio_tone'
/tmp/cc5sSG5R.o: In function `generate_test_tones':
/home/8bit_coder/minimodem-master/src/minimodem.c:295: undefined reference to `simpleaudio_get_rate'
/home/8bit_coder/minimodem-master/src/minimodem.c:295:(.text+0x59d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `simpleaudio_get_rate'
/home/8bit_coder/minimodem-master/src/minimodem.c:299: undefined reference to `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:299:(.text+0x5dd): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:300: undefined reference to `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:300:(.text+0x5eb): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `simpleaudio_tone'
/tmp/cc5sSG5R.o: In function `fsk_transmit_frame':
/home/8bit_coder/minimodem-master/src/minimodem.c:109: undefined reference to `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:109:(.text+0x170): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `simpleaudio_tone'
/tmp/cc5sSG5R.o: In function `main':
/home/8bit_coder/minimodem-master/src/minimodem.c:751: undefined reference to `databits_decode_ascii8'
/home/8bit_coder/minimodem-master/src/minimodem.c:751:(.text.startup+0xa6): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `databits_decode_ascii8'
/home/8bit_coder/minimodem-master/src/minimodem.c:751: undefined reference to `databits_encode_ascii8'
/home/8bit_coder/minimodem-master/src/minimodem.c:751:(.text.startup+0xc6): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `databits_encode_ascii8'
/tmp/cc5sSG5R.o: In function `benchmarks':
/home/8bit_coder/minimodem-master/src/minimodem.c:324: undefined reference to `simpleaudio_tone_init'
/home/8bit_coder/minimodem-master/src/minimodem.c:324:(.text.startup+0x2b3): additional relocation overflows omitted from the output
/home/8bit_coder/minimodem-master/src/minimodem.c:326: undefined reference to `simpleaudio_open_stream'
/home/8bit_coder/minimodem-master/src/minimodem.c:332: undefined reference to `simpleaudio_close'
/home/8bit_coder/minimodem-master/src/minimodem.c:334: undefined reference to `simpleaudio_open_stream'
/home/8bit_coder/minimodem-master/src/minimodem.c:340: undefined reference to `simpleaudio_close'
/home/8bit_coder/minimodem-master/src/minimodem.c:344: undefined reference to `simpleaudio_tone_init'
/home/8bit_coder/minimodem-master/src/minimodem.c:346: undefined reference to `simpleaudio_open_stream'
/home/8bit_coder/minimodem-master/src/minimodem.c:352: undefined reference to `simpleaudio_close'
/home/8bit_coder/minimodem-master/src/minimodem.c:354: undefined reference to `simpleaudio_open_stream'
/home/8bit_coder/minimodem-master/src/minimodem.c:360: undefined reference to `simpleaudio_close'
/tmp/cc5sSG5R.o: In function `main':
/home/8bit_coder/minimodem-master/src/minimodem.c:665: undefined reference to `databits_decode_baudot'
/home/8bit_coder/minimodem-master/src/minimodem.c:666: undefined reference to `baudot_encode'
/home/8bit_coder/minimodem-master/src/minimodem.c:797: undefined reference to `databits_decode_baudot'
/home/8bit_coder/minimodem-master/src/minimodem.c:798: undefined reference to `baudot_encode'
/home/8bit_coder/minimodem-master/src/minimodem.c:864: undefined reference to `databits_decode_binary'
/home/8bit_coder/minimodem-master/src/minimodem.c:945: undefined reference to `simpleaudio_tone_init'
/home/8bit_coder/minimodem-master/src/minimodem.c:954: undefined reference to `simpleaudio_open_stream'
/tmp/cc5sSG5R.o: In function `fsk_transmit_stdin':
/home/8bit_coder/minimodem-master/src/minimodem.c:130: undefined reference to `simpleaudio_get_rate'
/tmp/cc5sSG5R.o: In function `main':
/home/8bit_coder/minimodem-master/src/minimodem.c:975: undefined reference to `simpleaudio_close'
/home/8bit_coder/minimodem-master/src/minimodem.c:805: undefined reference to `databits_decode_baudot'
/home/8bit_coder/minimodem-master/src/minimodem.c:806: undefined reference to `baudot_encode'
/home/8bit_coder/minimodem-master/src/minimodem.c:988: undefined reference to `simpleaudio_open_stream'
/home/8bit_coder/minimodem-master/src/minimodem.c:995: undefined reference to `simpleaudio_get_rate'
/home/8bit_coder/minimodem-master/src/minimodem.c:1011: undefined reference to `fsk_plan_new'
/home/8bit_coder/minimodem-master/src/minimodem.c:1232: undefined reference to `fsk_find_frame'
/home/8bit_coder/minimodem-master/src/minimodem.c:1443: undefined reference to `simpleaudio_close'
/home/8bit_coder/minimodem-master/src/minimodem.c:1445: undefined reference to `fsk_plan_destroy'
/home/8bit_coder/minimodem-master/src/minimodem.c:833: undefined reference to `databits_decode_callerid'
/home/8bit_coder/minimodem-master/src/minimodem.c:998: undefined reference to `simpleaudio_set_rxnoise'
/tmp/cc5sSG5R.o: In function `fsk_transmit_stdin':
/home/8bit_coder/minimodem-master/src/minimodem.c:211: undefined reference to `simpleaudio_tone'
/home/8bit_coder/minimodem-master/src/minimodem.c:233: undefined reference to `simpleaudio_tone'
/tmp/cc5sSG5R.o: In function `main':
/home/8bit_coder/minimodem-master/src/minimodem.c:1132: undefined reference to `simpleaudio_read'
/home/8bit_coder/minimodem-master/src/minimodem.c:1340: undefined reference to `fsk_find_frame'
/home/8bit_coder/minimodem-master/src/minimodem.c:1155: undefined reference to `fsk_detect_carrier'
/home/8bit_coder/minimodem-master/src/minimodem.c:1186: undefined reference to `fsk_set_tones_by_bandshift'
/home/8bit_coder/minimodem-master/src/minimodem.c:845: undefined reference to `databits_decode_uic_ground'
/home/8bit_coder/minimodem-master/src/minimodem.c:833: undefined reference to `databits_decode_callerid'
/home/8bit_coder/minimodem-master/src/minimodem.c:843: undefined reference to `databits_decode_uic_train'
/tmp/cc5sSG5R.o:minimodem.c:(.rdata$.refptr.databits_decode_binary[.refptr.databits_decode_binary]+0x0): undefined reference to `databits_decode_binary'
/tmp/cc5sSG5R.o:minimodem.c:(.rdata$.refptr.databits_decode_uic_train[.refptr.databits_decode_uic_train]+0x0): undefined reference to `databits_decode_uic_train'
/tmp/cc5sSG5R.o:minimodem.c:(.rdata$.refptr.databits_decode_uic_ground[.refptr.databits_decode_uic_ground]+0x0): undefined reference to `databits_decode_uic_ground'
/tmp/cc5sSG5R.o:minimodem.c:(.rdata$.refptr.databits_decode_callerid[.refptr.databits_decode_callerid]+0x0): undefined reference to `databits_decode_callerid'
/tmp/cc5sSG5R.o:minimodem.c:(.rdata$.refptr.databits_encode_ascii8[.refptr.databits_encode_ascii8]+0x0): undefined reference to `databits_encode_ascii8'
/tmp/cc5sSG5R.o:minimodem.c:(.rdata$.refptr.databits_decode_ascii8[.refptr.databits_decode_ascii8]+0x0): undefined reference to `databits_decode_ascii8'
/tmp/cc5sSG5R.o:minimodem.c:(.rdata$.refptr.baudot_encode[.refptr.baudot_encode]+0x0): undefined reference to `baudot_encode'
/tmp/cc5sSG5R.o:minimodem.c:(.rdata$.refptr.databits_decode_baudot[.refptr.databits_decode_baudot]+0x0): undefined reference to `databits_decode_baudot'
collect2: error: ld returned 1 exit status

Then I thought maybe I needed to list every file: 然后我想也许我需要列出每个文件:

gcc -o baudot.c baudot.h databits.h databits_ascii.c databits_baudot.c databits_binary.c databits_callerid.c databits_uic.c fsk.c fsk.h minimodem.c simpleaudio.c simpleaudio.h simpleaudio_internal.h simpleaudio-alsa.c simpleaudio-benchmark.c simpleaudio-pulse.c simpleaudio-sndfile.c simple-tone-generator.c uic_codes.c uic_codes.h gcc -o baudot.c baudot.h databits.h databits_ascii.c databits_baudot.c databits_binary.c databits_callerid.c databits_uic.c fsk.c fsk.h minimodem.c simpleaudio.c simpleaudio.h simpleaudio_internal.h simpleaudio-alsa。 simpleaudio-benchmark.c simpleaudio-pulse.c simpleaudio-sndfile.cimple-tone-generator.cuic_codes.cuic_codes.h

But that gave a load of different errors: 但这带来了许多不同的错误:

/tmp/ccmwpyzy.o:databits_baudot.c:(.text+0x1f): undefined reference to `baudot_reset'
/tmp/ccmwpyzy.o:databits_baudot.c:(.text+0x1f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `baudot_reset'
/tmp/ccmwpyzy.o:databits_baudot.c:(.text+0x3d): undefined reference to `baudot_decode'
/tmp/ccmwpyzy.o:databits_baudot.c:(.text+0x3d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `baudot_decode'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x1b8): undefined reference to `fftwf_malloc'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x1b8): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fftwf_malloc'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x208): undefined reference to `fftwf_malloc'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x208): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fftwf_malloc'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x281): undefined reference to `fftwf_plan_many_dft_r2c'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x281): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fftwf_plan_many_dft_r2c'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x2cc): undefined reference to `fftwf_free'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x2cc): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fftwf_free'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x2dc): undefined reference to `fftwf_free'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x2dc): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fftwf_free'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x323): undefined reference to `fftwf_free'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x323): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fftwf_free'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x333): undefined reference to `fftwf_free'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x333): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fftwf_free'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x343): undefined reference to `fftwf_destroy_plan'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x343): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fftwf_destroy_plan'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x454): undefined reference to `fftwf_execute'
/tmp/cc6Uh66Z.o:fsk.c:(.text+0x454): additional relocation overflows omitted from the output
/tmp/cc6Uh66Z.o:fsk.c:(.text+0xda7): undefined reference to `fftwf_execute'
/tmp/ccmR4Dzs.o:minimodem.c:(.rdata$.refptr.baudot_encode[.refptr.baudot_encode]+0x0): undefined reference to `baudot_encode'
/tmp/ccBHdt9j.o:simpleaudio.c:(.rdata$.refptr.simpleaudio_backend_alsa[.refptr.simpleaudio_backend_alsa]+0x0): undefined reference to `simpleaudio_backend_alsa'
/tmp/ccBHdt9j.o:simpleaudio.c:(.rdata$.refptr.simpleaudio_backend_pulseaudio[.refptr.simpleaudio_backend_pulseaudio]+0x0): undefined reference to `simpleaudio_backend_pulseaudio'
collect2: error: ld returned 1 exit status

At this point I don't know what to do since it compiles fine and runs on Linux but using Cygwin to compile it on windows does that. 在这一点上,我不知道该怎么办,因为它可以很好地编译并可以在Linux上运行,但是使用Cygwin在Windows上进行编译可以做到。 If anyone has any idea about what I'm doing wrong or how I can fix the command or files so that it works, thanks. 如果有人对我做错了什么或如何修复命令或文件有任何想法,谢谢。

As stated by @Sami Kuhmonen in a comment to your question: 如@Sami Kuhmonen在对您的问题的评论中所述:

Not all code can be compiled on different systems. 并非所有代码都可以在不同的系统上编译。 If the code requires a specific audio system, it might not be available 如果代码需要特定的音频系统,则可能不可用

In this case the three libraries it tries to use but fails at: 在这种情况下,它尝试使用三个库,但在以下位置失败:

  • PulseAudio : A sound system for POSIX OSs (not windows, however : has been tested on Windows 2000 and Windows XP) So windows support would be very limited at best in my opinion PulseAudio :适用于POSIX操作系统的声音系统(不是Windows,但是:已经在Windows 2000和Windows XP上进行了测试),所以我认为Windows支持最多是有限的
  • ALSA : It states in its name Advanced Linux Sound Architecture (probably not windows right?) This is Linux specific code for communicating with sound card drivers on Linux platforms. ALSA :其名称为Advanced Linux Sound Architecture(可能不是Windows吧?),这是Linux专用代码,用于与Linux平台上的声卡驱动程序进行通信。
  • libsndfile : It says on the website it has pre-compiled binaries for Win32 and Win64 OSs, but it doesn't look like originally it was designed with windows in mind libsndfile :它说在网站上它已经为Win32和Win64 OS预先编译了二进制文件,但是看起来与最初设计时考虑到Windows不同

All in all, audio code like this is probably trying to communicate with specific drivers designed only for a Linux based system ( Linux vs Windows Audio in 2017 ). 总而言之,像这样的音频代码可能正在尝试与仅针对基于Linux的系统设计的特定驱动程序进行通信( 2017年为Linux vs Windows Audio )。 And although C can be portable across different OSs, the code written here in the libraries you are compiling your program with, is most likely not. 尽管C可以跨不同的操作系统移植,但您编写程序所使用的库中此处编写的代码很可能不会。

I'm pretty sure you would have to edit (port) the source code to work with more relavant windows audio programming in mind. 我敢肯定,您必须编辑(移植)源代码才能使用更多相关的Windows音频编程。

Note: 注意:

Thanks to the comment from @matzeri, there's actually a libsndfile package on Cygwin. 感谢@matzeri的评论,实际上Cygwin上有一个libsndfile软件包。 See the link here . 这里查看链接

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

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