1

I want to show weather data on my Waveshare e-Paper display using an Raspberry Zero. Controlling the display works fine with the provided library. On the other hand I'm loading the weather data with a PHP script from a database. For this I'm using a HTTP-Post request with the CURL library. This works also fine. Now I want to combine both "projects", so I included "curl/curl.h" to the exemplary Waveshare project but I get a "undefined reference error". I know that some how a link to the CURL library is missing in the Makefile, but I never worked with Makefiles before. Currently I'm using the Makefile provided in the Waveshare library (https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/c/Makefile).

I would be really happy for any support. I already tried hints from here (How to use external libraries and headers in C Makefile?), but I don't know how to adjust this for my makefile...

Thanks in advance Andy

andy_l90
  • 11
  • 1

1 Answers1

1

curl needs to be linked to the executables in the recipes when compiling and linking. This is done by adding -lcurl to gcc's arguments.

The makefile you linked to doesn't make use of LDFLAGS so there are a couple of options here:

  1. When you run make, supply the linker option in CFLAGS like so: CFLAGS="-lcurl" make. This adds the appropriate linker argument for curl to the build commands in the Makefile
  2. Modify the Makefile to include -lcurl where needed.

Option 1 requires no changes to the Makefile, but you'll have to remember to set the CFLAGS variable each time you run make. Option 2 requires changes to the Makefile but will then do the right thing when you run make on its own.

drew010
  • 68,777
  • 11
  • 134
  • 162