Skip to content

Instantly share code, notes, and snippets.

@k-okada
Last active March 23, 2022 08:28
Show Gist options
  • Save k-okada/8a19f3ad507633f64d88852570042ad3 to your computer and use it in GitHub Desktop.
Save k-okada/8a19f3ad507633f64d88852570042ad3 to your computer and use it in GitHub Desktop.
int func() {
return 100;
}
#include <stdio.h>
extern int func();
int main() {
int a = func();
printf("a - %d\n", a);
}
all: main.o libfunc.so main
main:
gcc -o main main.o -Wl,-rpath=. -L. -lfunc
main.o: main.cpp
gcc -c main.cpp
nm main.o
libfunc.so: func.cpp
gcc -shared -o libfunc.so func.cpp
nm libfunc.so
clean:
-rm main main.o libfunc.so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment