Last active
February 9, 2023 07:28
-
-
Save ardrabczyk/6aeb8545c9b754d6b15be390af4bdff0 to your computer and use it in GitHub Desktop.
Shared object with rpath set
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 <stdio.h> | |
void foo(void) | |
{ | |
puts("I'm in foo()"); | |
} |
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
void foo(void); |
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 <stdio.h> | |
void bar(void) | |
{ | |
puts("I'm in bar()"); | |
} |
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
void bar(void); |
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 <stdio.h> | |
#include <stdlib.h> | |
#include "lib_two.h" | |
int main(void) | |
{ | |
bar(); | |
return EXIT_SUCCESS; | |
} |
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
all: | |
cc -shared -fPIC lib_one.c lib_one.h -o libone.so | |
cc -shared -fPIC lib_two.c lib_two.h -o libtwo.so -L. -lone -Wl,-rpath=libs | |
mkdir -p libs | |
mv libone.so libs | |
cc main.c -o main -L. -ltwo -Wl,-rpath=. | |
clean: | |
rm -f libone.so libone.a libtwo.so main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment