As soon as I installed Ubuntu 11.10, a strange error appears. I want to use GD with my C program, so I installed the package "libgd2-xpm-dev". Everything was installed - the files gd.h and libgd.a are in "/ usr / include" and in "/ usr / lib". So, I tried to compile a simple program using GD.
int main()
{
gdImagePtr im, im_clear;
int black, white;
FILE *out1;
im = gdImageCreate(100, 100);
im_clear = gdImageCreate(100, 100);
white = gdImageColorAllocate(im, 255, 255, 255);
black = gdImageColorAllocate(im, 0, 0, 0);
return 0;
}
$ gcc -lgd gd.c
/tmp/cc6LReuX.o: In function `main':
gd2.c:(.text+0x19): undefined reference to `gdImageCreate'
gd2.c:(.text+0x31): undefined reference to `gdImageCreate'
gd2.c:(.text+0x59): undefined reference to `gdImageColorAllocate'
gd2.c:(.text+0x81): undefined reference to `gdImageColorAllocate'
Wait what? Ok, let's check something out.
$ gcc -lgd_something gd.c
/usr/bin/ld: cannot find -lgd_something
$ nm /usr/lib/libgd.a
...
00000dc0 T gdImageColorAllocate
...
000003b0 T gdImageCreate
$ gcc -lgd gd.c
/tmp/cc6LReuX.o: In function `main':
gd2.c:(.text+0x19): undefined reference to `gdImageCreate'
gd2.c:(.text+0x31): undefined reference to `gdImageCreate'
gd2.c:(.text+0x59): undefined reference to `gdImageColorAllocate'
gd2.c:(.text+0x81): undefined reference to `gdImageColorAllocate'
$ echo $LD_LIBRARY_PATH
And I don’t know what to do. Is this a bug in gcc or something is wrong. On my previous os (Ubuntu 10.04) everything works fine. Which file should I show you?
source
share