不幸的是,我找不到有关如何使用giflib的任何初学者友好教程。
这是我的代码:
#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);
}
我尝试这样编译它:
g++ main.cpp
但是会产生此错误:
/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
我在Ubuntu 20.04上,并且已经安装了libgif-dev
软件包。
如何链接giflib库以使功能正常工作?
尝试随机发现: