I wrote a program (myreader.c) to manipulate a RFID reader.
I compile by type “make” in the root of the package, makefile is shown below
# 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
and it works well on my original machine(64 bits, Ubuntu 12.04 LTS), and the only problem is, when I type make, the warning info would come up.
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
But /bin/myreader works well.
However, when I move the package to another machine(64 bits, Ubuntu 11.10), and type make in the same way as in the original machine.
Error messages in the below appears:
berln@ubuntu:~/桌面/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
I have no ideas why this error happened on only one machine instead of both.
If you need more information, you can download the package here.
Thanks in advance.
Most likely your
nfclibrary is missing or not installed properly on your other computer.One of the options you pass to the linker is
-lnfc, which tells it to link to thenfclibrary. Your errors are coming from the linker, which cannot find thenfc_configureand othernfc_symbols. This means that the linker cannot find these symbols. Check thenfclibrary installation.