Eclipse not finding SDK library

Hello everyone,

I’m having some trouble running a simple GPIO example using the libgpiod library.

After setting up Eclipse following this tutorial I tried to build the demo code. However, I’m getting the error undefined reference to the libgpiod functions.

My sample code:

#include <stdbool.h>
#include <stdio.h>
#include <gpiod.h>

int main(void) {
	struct gpiod_chip *output_chip;
	struct gpiod_line *output_line;

	//	Configure a GPIO as output:

	/* open the GPIO bank */
	output_chip = gpiod_chip_open_by_number(1);

	/* open the GPIO line */
	output_line = gpiod_chip_get_line(output_chip, 1);

	/* config as output and set a description */
	gpiod_line_request_output(output_line, "gpio-test",GPIOD_LINE_ACTIVE_STATE_HIGH);

	//	Toggle a GPIO:

	while (1) {
		/* Clear */
		int line_value = 0;
		gpiod_line_set_value(output_line, line_value);

		/* Set */
		line_value = 1;
		gpiod_line_set_value(output_line, line_value);

	return 0;

What I’ve tried and verified so far:

  • I’m setting up the SDK environment and then starting eclipse on the same terminal window
  • Eclipse can find the #include <gpiod.h>
  • I can find the gpiod.h on the project’s includes folder

Hi @farina!

Which SDK are you using for this project?

Your SDK has got to have the libgpiod includes so the linker can find the references to these functions.

You may have to build a new SDK using OpenEmbedded.

Hello @gustavo.tx

I am using the SDK generated by bitbake for my custom image.

I can find the libgpiod includes on my SDK, but just to make sure, this are all gpio related files on my SDK folder:


Also, I checked the image recipes with this command:

bitbake -g console-tdx-image && cat | grep -v -e '-native' | grep -v digraph | grep -v -e '-image' | awk '{print $1}' | sort | uniq

And the libgpiod shows up on the list.

Hi @farina!

Your SDK looks fine. This looks like some issue with Eclipse and its configuration.

I’ll give this a try and let you know if I can reproduce it.


I used this tutorial to configure Eclipse.

Also, you can download my SDK here

Just an update,

I’m also having the same problem with the pthread library


Did you tell the linker that you want to link libgpiod and pthreads?

I.e. did you add (in addition to ${LDFLAGS}) -lgpiod -lpthread to the linker flags. Please refer to step 15 of the tutorial.



As my colleague @max.tx mentioned, you have to add the flags for the libraries you’re trying to use on the linker call.
If you’re following the tutorial, on step 15 we use the ${LDFLAGS} environment variable. Add -lgpiod and -pthread so it’ll be like ${LDFLAGS} -lgpiod -lpthread.

Hello Max,

No I didn’t and this solved my problem!

Thank you


Hi Mauricio

What error did you get? Maybe it’s the missing l in the answer above, which I corrected now.