Skip to content

Instantly share code, notes, and snippets.

@dcki
Created January 10, 2017 06:32
Show Gist options
  • Select an option

  • Save dcki/37d4eea7dc37285899454633235fb652 to your computer and use it in GitHub Desktop.

Select an option

Save dcki/37d4eea7dc37285899454633235fb652 to your computer and use it in GitHub Desktop.
cat > bar.c << EOF
#include<stdio.h>
void bar() { printf("hello!\n"); }
EOF
gcc bar.c -fpic -shared -o libbar.so
cat > bar.h << EOF
void bar();
EOF
cat > foo.c << EOF
#include "bar.h"
int main() {
bar();
return 0;
}
EOF
gcc foo.c -I. -lbar -L.
sudo ldconfig $PWD
./a.out
# => hello!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment