0

I am trying to use a library provided by course module in C.

I have the following installed:

  • MinGW32 - Base
  • Visual Code

Hello.c

#include <stdio.h>
#include "libcs1010/include/cs1010.h"
int main()
{
   // library method
   cs1010_print_double(10);
   printf("Hello, World!");
   return 0;
}

Error

undefined reference to `cs1010_print_double'
collect2.exe: error: ld returned 1 exit status

Directory Structure:

└───hello.c
└───libcs1010
    ├───include
    |     └───cs1010.h
    ├───lib
    |     └───libcs1010.a
    └───src
          └───cs1010.c

How can I run GCC such that i can link to the libcs1010.a file?

Carrein
  • 3,231
  • 7
  • 36
  • 77
  • 1
    Possible duplicate of [Telling gcc directly to link a library statically](https://stackoverflow.com/questions/6578484/telling-gcc-directly-to-link-a-library-statically) – Dori Aug 21 '18 at 08:04
  • 1
    Add the library as if it were an seperate object file. `gcc -c hello.c` `gcc -o hello hello.o libcs1010.a` – hetepeperfan Aug 21 '18 at 08:24

0 Answers0