RFIDリーダーを操作するプログラム(myreader.c)を作成しました。 (64ビット、Ubuntuの12.04 LTS)、そして唯一の問題を、私は、パッケージのルートにあるタイプ「作る」ことでコンパイル別のマシンでコンパイルするときにgccで定義されていない参照エラー
は、メイクファイルは
# CC and CFLAGS are varilables
CC=gcc
CFLAGS = -c
# -c option ask g++ to compile the source files, but do not link.
# -g option is for debugging version
# -O2 option is for optimized version
OPTFLAGS = -O2 -g
myreader : src/myreader.c
$(CC) $(OPTFLAGS) src/myreader.c src/crypto1.c src/nfc-utils.c -lnfc -o ./bin/myreader
# clean all the .o and executable files
clean:
rm -rf bin/myreader
下に表示され、それは私の元のマシンに適しています私がmakeとタイプすると、警告情報が出ます。
src/myreader.c:519:6: warning: conflicting types for ‘printResult’ [enabled by default]
src/myreader.c:211:3: note: previous implicit declaration of ‘printResult’ was here
ただし、/ bin/myreaderはうまくいきます。
しかしながら、Iは、元のマシンと同様に別のマシン(64ビットのUbuntu 11.10)、およびタイプにするためにパッケージを移動します。以下で
エラーメッセージが表示されます:
[email protected]:~/桌面/useful code$ make
gcc -O2 -g src/myreader.c src/crypto1.c src/nfc-utils.c -lnfc -o ./bin/myreader
src/myreader.c:519:6: warning: conflicting types for ‘printResult’ [enabled by default]
src/myreader.c:211:3: note: previous implicit declaration of ‘printResult’ was here
/tmp/ccrKvhjm.o: In function `mf_enhanced_auth':/home/berln/桌面/useful code/src/myreader.c:373: undefined reference to `nfc_configure'
/home/berln/桌面/useful code/src/myreader.c:380: undefined reference to `nfc_configure'
/home/berln/桌面/useful code/src/myreader.c:390: undefined reference to `nfc_configure'
/home/berln/桌面/useful code/src/myreader.c:434: undefined reference to `nfc_configure'
/tmp/ccrKvhjm.o: In function `mf_configure':
/home/berln/桌面/useful code/src/myreader.c:484: undefined reference to `nfc_configure'
/tmp/ccrKvhjm.o:/home/berln/桌面/useful code/src/myreader.c:489: more undefined references to `nfc_configure' follow
/tmp/ccrKvhjm.o: In function `main':
/home/berln/桌面/useful code/src/myreader.c:155: undefined reference to `nfc_connect'
/home/berln/桌面/useful code/src/myreader.c:213: undefined reference to `nfc_disconnect'
collect2: ld returned 1 exit status
make: *** [myreader] Error 1
私はこのエラーではなく、両方の1台のマシンにのみなぜ起こったか何のアイデアを持っていません。
さらに詳しい情報が必要な場合は、hereパッケージをダウンロードできます。
ありがとうございます。
nfc_configureはどこで宣言されていますか?コードを参照する必要があります – Mark
'printResult'関数を使用する前に宣言する必要があるため、最初のエラー(' printResult 'の型が間違っています)が原因です。最も簡単なのは、初めて使用する前に移動することです。 –
マークする:nfc_configureはパッケージ内のsrc/nfc.cの183行目で宣言されています。 –