Skip to content

Instantly share code, notes, and snippets.

@shinh
Last active August 29, 2015 14:00
Show Gist options
  • Save shinh/c070a213b3d56aa54e34 to your computer and use it in GitHub Desktop.
Save shinh/c070a213b3d56aa54e34 to your computer and use it in GitHub Desktop.
// gcc -fPIC -shared z.c -o libz.so
#include <stdio.h>
void func() {
puts("z");
}
// gcc -fPIC -shared y.c -o liby.so -L. -lz
#include <stdio.h>
void func() {
puts("y");
}
void func_in_y() {
func();
}
// gcc x.c -o x -L. -ly
#include <stdio.h>
void func() {
puts("x");
}
int main() {
func_in_y();
return 0;
}
// LD_LIBRARY_PATH=. ./x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment