paolo-caroni / ps3mca-ps1

A program to read and write PS1 memory card with the Memory Card Adaptor CECHZM1 (SCPH-98042)
GNU General Public License v3.0
57 stars 10 forks source link

Fix makefile #7

Closed jsantangelo-rl closed 2 years ago

jsantangelo-rl commented 2 years ago

For whatever reason, I get this error trying to compile the project on Ubuntu 20.04:

cc -I/usr/include/libusb-1.0 -lusb-1.0 src/main.c -o ps3mca-ps1
src/main.c: In function ‘main’:
src/main.c:1054:42: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]
 1054 |         fprintf(stderr, "Unknown option %s\n", argv[1][0]);
      |                                         ~^     ~~~~~~~~~~
      |                                          |            |
      |                                          char *       int
      |                                         %d
/usr/bin/ld: /tmp/cc6HIKrF.o: in function `open_ps3mca':
main.c:(.text+0x5b): undefined reference to `libusb_init'
/usr/bin/ld: main.c:(.text+0xb5): undefined reference to `libusb_open_device_with_vid_pid'
/usr/bin/ld: main.c:(.text+0x126): undefined reference to `libusb_kernel_driver_active'
/usr/bin/ld: main.c:(.text+0x13e): undefined reference to `libusb_detach_kernel_driver'
/usr/bin/ld: main.c:(.text+0x195): undefined reference to `libusb_claim_interface'
/usr/bin/ld: /tmp/cc6HIKrF.o: in function `close_ps3mca':
main.c:(.text+0x1ef): undefined reference to `libusb_release_interface'
/usr/bin/ld: main.c:(.text+0x23d): undefined reference to `libusb_attach_kernel_driver'
/usr/bin/ld: main.c:(.text+0x247): undefined reference to `libusb_exit'
/usr/bin/ld: /tmp/cc6HIKrF.o: in function `PS3mca_verify_card':
main.c:(.text+0x2d9): undefined reference to `libusb_bulk_transfer'
/usr/bin/ld: main.c:(.text+0x35f): undefined reference to `libusb_bulk_transfer'
/usr/bin/ld: /tmp/cc6HIKrF.o: in function `PS1_get_id':
main.c:(.text+0x547): undefined reference to `libusb_bulk_transfer'
/usr/bin/ld: main.c:(.text+0x5d0): undefined reference to `libusb_bulk_transfer'
/usr/bin/ld: /tmp/cc6HIKrF.o: in function `PS1_read':
main.c:(.text+0x9e8): undefined reference to `libusb_bulk_transfer'
/usr/bin/ld: /tmp/cc6HIKrF.o:main.c:(.text+0xa63): more undefined references to `libusb_bulk_transfer' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:6: ps3mca-ps1] Error 1

Moving CFLAGS and LDFLAGS around to the end of the compile statements seems to fix this.