0

Unfortunately, I couldn't find any beginner friendly tutorial on how to use giflib.

This is my code:

#include <iostream>
#include <gif_lib.h>

int main(int argc, char** argv) 
{
    if (argc < 2)
    {
        std::cerr << "No argument" << std::endl;
        return 1;
    }

    GifFileType *gifFile = DGifOpenFileName(argv[1], NULL);
    DGifSlurp(gifFile);
}

I try to compile it like this:

g++ main.cpp

but it yields this error:

/usr/bin/ld: /tmp/ccd5G2QR.o: in function `main':
main.cpp:(.text+0x5c): undefined reference to `DGifOpenFileName'
/usr/bin/ld: main.cpp:(.text+0x6c): undefined reference to `DGifSlurp'
collect2: error: ld returned 1 exit status

I'm on Ubuntu 20.04 and I've installed the libgif-dev package.

How to link the giflib library for the functions to work?

user1785730
  • 3,150
  • 4
  • 27
  • 50
  • [Failure to link against appropriate libraries/object files or compile implementation files](https://stackoverflow.com/a/12574400/1362568) – Mike Kinghan May 03 '20 at 22:20
  • Yeah sure, but what’s the name of the library? (Found it already, as you can see in my own answer.) But that was the question. – user1785730 May 03 '20 at 22:24

1 Answers1

0

Trying randomly around I found it's:

g++ main.cpp -lgif
user1785730
  • 3,150
  • 4
  • 27
  • 50