0

I am trying to run a code for FT245RL chip in kubuntu version 18.04. Which requires lftdi library. But it shows the error as undefined reference to ftdi_init

I have tried removing and installing the libraries again. I also tried to give the path in the command to execute. I even tried many improvized commands across the internet but was unable to succeed.

if (ftdi_init(&ftdic) < 0)
{
    fprintf(stderr, "ftdi_init failed\n");
    return EXIT_FAILURE;
}

f = ftdi_usb_open(&ftdic, 0x0403, 0x6001);

if (f < 0 && f != -5)
{
    fprintf(stderr, "unable to open ftdi device: %d (%s)\n", f, ftdi_get_error_string(&ftdic));
    exit(-1);
}

The expected result is just to compile the program without any errors.

  • You have to include the header file that is needed for it. search for the ftdi_init in the header files, if you find that in header file add that header file into your source code to run. make sure you link the library when you compile it. – danglingpointer May 28 '19 at 09:33
  • Check this out: https://stackoverflow.com/q/14872888/7640269 – danglingpointer May 28 '19 at 09:34
  • Hi dangling pointer , I have included the header file #include the necessary one. The link you have suggested is the one I tried many times still I get the same error message. – Sai Bharath May 28 '19 at 10:07
  • Please update/edit your code to the newest version so new readers are on the same page. Additionally please provide information how you compile your project including the tested commands. Can you localize the correct ftdi.h file on your system and can you find the definition of ftdi_init inside of it? – Christian B. May 28 '19 at 14:01

1 Answers1

0

I used:
gcc -lftdi -o test test.c

And it worked

Alexander Ushakov
  • 5,139
  • 3
  • 27
  • 50
Pa0rba
  • 11
  • Pa0rba, a link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it is there, then quote the most relevant part of the page you are linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](/help/deleted-answers) – Luca Kiebel Feb 10 '22 at 11:54