Created
December 3, 2021 06:56
-
-
Save cho0h5/547246363f737dfdaf0e91ec5318adbb to your computer and use it in GitHub Desktop.
C 동적 라이브러리
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 -fPIC -c control_light.c | |
// gcc -shared -Wl,-soname,libcontrollight.so.0 -o libcontrollight.so.0.0.0 control_light.o | |
// sudo cp libcontrollight.so.0.0.0 /usr/local/lib/ | |
// sudo ln -s /usr/local/lib/libcontrollight.so.0.0.0 /usr/local/lib/libcontrollight.so.0 | |
// sudo ln -s /usr/local/lib/libcontrollight.so.0.0.0 /usr/local/lib/libcontrollight.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int turn_on(int id); | |
int turn_off(int id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "control_light.h" | |
int main() { | |
turn_on(13); | |
turn_on(7); | |
turn_off(13); | |
turn_on(7); | |
return 0; | |
} | |
// export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ | |
// gcc main.c -L/usr/local/lib -lcontrollight |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment