How do I link in gcc to a C library created by min?

Asked

Viewed 42 times

0

I created a simple library in the C language, example. h and example. c, and includes it in a third code called (code. c).

Only when compiling this third code:

gcc code. c -o code.out

Gave Undefined error to :"name of the functions I used"

I soon realized I needed to link to the library but?

How do I link in the gcc of a library created by me?

PS: linux usage (Raspbian)

  • It’s not just compiling the library together? gcc -o codigo.out codigo.c exemplo.c - https://stackoverflow.com/q/15441877

1 answer

0

You need to add them to the main file only. For example:

// Bibliotecas "built-in"
#include <stdlib.h>
#include <time.h>

// Suas bibliotecas (O endereço para cada uma)
#include "tool/args/options.c"
#include "tool/args/validation.c"
#include "tool/define/type.c"
#include "tool/file/write-to-file.c"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.