繁体   English   中英

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

[英]Trouble compiling linux C program in cygwin

我试图在Cygwin中为Linux编译一个名为minimodem的程序,因为我希望能够在Windows中运行它。 这是一个简单的命令行程序,我安装了Cygwin,基本上使用了所有必需的库来进行编译。

其中的一些库是:已安装所有音频,视频,数学,编译,开发,api以及系统和基础。

我遇到的第一个问题是./configure。 从github中项目的源代码来看,没有配置文件或文件夹。 我决定放弃它,而是直接使用make并引用该文件夹中的所有文件。

首先发生的事情是我得到了这个错误:

minimodem.c:在函数“ main”中:minimodem.c:556:4:错误:#error必须启用{USE_PULSEAUDIO,USE_ALSA,USE_SNDFILE}中的至少一个! #错误必须启用{USE_PULSEAUDIO,USE_ALSA,USE_SNDFILE}中的至少一个! ^ ~~~~

因此,我进入代码并删除了检查音频驱动程序的部分(即使Cygwin有可用的所有音频库),然后我再次尝试了它:

gcc -o minimodem.c

然后编译器走得更远,然后出现此错误:

/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

然后我想也许我需要列出每个文件:

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

但这带来了许多不同的错误:

/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

在这一点上,我不知道该怎么办,因为它可以很好地编译并可以在Linux上运行,但是使用Cygwin在Windows上进行编译可以做到。 如果有人对我做错了什么或如何修复命令或文件有任何想法,谢谢。

如@Sami Kuhmonen在对您的问题的评论中所述:

并非所有代码都可以在不同的系统上编译。 如果代码需要特定的音频系统,则可能不可用

在这种情况下,它尝试使用三个库,但在以下位置失败:

  • PulseAudio :适用于POSIX操作系统的声音系统(不是Windows,但是:已经在Windows 2000和Windows XP上进行了测试),所以我认为Windows支持最多是有限的
  • ALSA :其名称为Advanced Linux Sound Architecture(可能不是Windows吧?),这是Linux专用代码,用于与Linux平台上的声卡驱动程序进行通信。
  • libsndfile :它说在网站上它已经为Win32和Win64 OS预先编译了二进制文件,但是看起来与最初设计时考虑到Windows不同

总而言之,像这样的音频代码可能正在尝试与仅针对基于Linux的系统设计的特定驱动程序进行通信( 2017年为Linux vs Windows Audio )。 尽管C可以跨不同的操作系统移植,但您编写程序所使用的库中此处编写的代码很可能不会。

我敢肯定,您必须编辑(移植)源代码才能使用更多相关的Windows音频编程。

注意:

感谢@matzeri的评论,实际上Cygwin上有一个libsndfile软件包。 这里查看链接

暂无
暂无

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

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