簡體   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