0

I'm trying to compile a program in the terminal using gcc. I'm kind of new to do this so I'm making some experiments with link various libraries. However some are working and some aren't and I wonder why and what can I do to fix this. Here's a screenshot of what I have (which also includes my version of gcc if that's relevant.

enter image description here

  • Generic programming questions should be asked on [so]. – muru Feb 23 '17 at 11:35
  • 2
    Could you please post text files, dialogue messages, and program output listings as text, not as images? To achieve the latter two you can either 1) select, copy & paste the dialogue text or terminal content or 2) [save the program output to a file](//askubuntu.com/q/420981/175814) and use that. Longer listings (≥100 lines) should be uploaded to a [pastie service](https://paste.ubuntu.com/) and linked to in the question. Thanks. – David Foerster Feb 23 '17 at 16:15

1 Answers1

3

You have an error with -lgd. Do you have libgd-dev installed?

guest@desktop /tmp $ cat helloworld.c
#include <stdio.h>

int main(int argc, char **argv)
{
    printf("Hello, world!\n");
    return 0;
}
guest@desktop /tmp $ gcc -o helloworld helloworld.c -lgd
/usr/bin/ld : ne peut trouver -lgd
collect2: error: ld returned 1 exit status
guest@desktop /tmp $ sudo aptitude install libgd-dev
guest@desktop /tmp $ gcc -o helloworld helloworld.c -lgd
guest@desktop /tmp $ ./helloworld 
Hello, world!
ngarnier
  • 146
  • 1