Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] libgd symbol link error under gcc

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
chisam
Posts: 4
Joined: 2018-05-27 15:57
Location: Eastern USA

[SOLVED] libgd symbol link error under gcc

#1 Post by chisam »

Hello,
Few years back I wrote a C program using libgd with the intent of producing JPG images with some line drawings and filled rectangles. That was probably on Fedora x86_64, if I remember.
As is, that compiled program fails to run under Debian Stretch 9.4 (amd64) saying "libjpeg.so.8: cannot open shared object file: No such file or directory".

Realizing I may need to compile that again under current Debian, tried gcc and it failed quickly with missing "gd.h" include file. Checked with Synaptic to see there is ligd3 (2.2.4-2+deb9u2) already installed but no libgd-dev. So, I install libgd-dev (2.2.4-2+deb9u2) and then it finds the "gd.h" in /use/include path.

However, gcc fails at link stage looking for gd-library symbols like gdImageJpeg, gdImageCreateTrueColor, gdImageLine, etc. Unresolved externals.

So, do I need to compile the GD library too? Or, is there a library that I missed during install? Note that there is no C++/Python/PERL, etc, just straight C.

Thanks.
Last edited by chisam on 2018-05-30 13:05, edited 1 time in total.

chisam
Posts: 4
Joined: 2018-05-27 15:57
Location: Eastern USA

Re: libgd symbol link error under gcc

#2 Post by chisam »

After some investigation with a cool head in the morning, I realize it was my error. :oops: See this below:

Code: Select all

/usr/lib/x86_64-linux-gnu$ ls -alt libgd*
lrwxrwxrwx 1 root root      29 Jan 14 18:04 libgdk_pixbuf-2.0.so.0 -> libgdk_pixbuf-2.0.so.0.3600.5
-rw-r--r-- 1 root root  146856 Jan 14 18:04 libgdk_pixbuf-2.0.so.0.3600.5
lrwxrwxrwx 1 root root      34 Jan 14 18:04 libgdk_pixbuf_xlib-2.0.so.0 -> libgdk_pixbuf_xlib-2.0.so.0.3600.5
-rw-r--r-- 1 root root   68168 Jan 14 18:04 libgdk_pixbuf_xlib-2.0.so.0.3600.5
-rw-r--r-- 1 root root  549372 Aug 31  2017 libgd.a
lrwxrwxrwx 1 root root      14 Aug 31  2017 libgd.so -> libgd.so.3.0.4
lrwxrwxrwx 1 root root      14 Aug 31  2017 libgd.so.3 -> libgd.so.3.0.4
-rw-r--r-- 1 root root  406184 Aug 31  2017 libgd.so.3.0.4
After copying the libgd.so.3.0.4 to a safe area...

Code: Select all

$ objdump -T libgd.so.3.0.4 | grep gdImageCreateTrueColor
000000000000e640 g    DF .text	000000000000026e  Base        gdImageCreateTrueColor


Just some flags were needed in gcc that I forgot to put in during compilation:-

Code: Select all

gcc -lgd -lpng -lz -ljpeg -lfreetype -lm -o  myObj  mySrc.c

Post Reply