October 22, 2024
Chicago 12, Melborne City, USA
C#

Include an external library in C


I’m attempting to use a C library for an opencourseware course from Harvard. The instructor’s instructions for setting up the external lib can be found here.

I am following the instructions specific to ubuntu as I am trying to use this lib on my ubuntu box. I followed the instructions on the page to set it up, but when I run a simple helloWorld.c program using a cs50 library function, gcc doesn’t want to play along.

Example:

helloWorld.c

#include <stdio.h>
#include <cs50.h>

int
main(void){
        printf("What do you want to say to the world?\n");
        string message = GetString();
        printf("%s!\n\n", message);
}

$ gcc helloWorld.c

/tmp/ccYilBgA.o: In function `main':
helloWorld.c:(.text+0x16): undefined reference to `GetString'
collect2: ld returned 1 exit status

I followed the instructions to the letter as stated in the instructions, but they didn’t work for me. I’m runing ubuntu 12.04. Please let me know if I can clarify further my problem.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video