Skip to content

Instantly share code, notes, and snippets.

@cho0h5
Last active December 3, 2021 06:22
Show Gist options
  • Save cho0h5/e869c6b0cbe0d61cee900cb4771d364d to your computer and use it in GitHub Desktop.
Save cho0h5/e869c6b0cbe0d61cee900cb4771d364d to your computer and use it in GitHub Desktop.
C 정적 라이브러리
#include "control_light.h"
#include <stdio.h>
int turn_on(int id) {
printf("turn on %d\n", id);
return 0;
}
int turn_off(int id) {
printf("turn off %d\n", id);
return 0;
}
// gcc -c control_light.c
// ar rc libcontrollight.a control_light.o
int turn_on(int id);
int turn_off(int id);
#include "control_light.h"
int main() {
turn_on(13);
turn_on(7);
turn_off(13);
turn_on(7);
return 0;
}
// gcc main.c -L./ -lcontrollight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment