Skip to content

Instantly share code, notes, and snippets.

@ardrabczyk
Last active February 9, 2023 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ardrabczyk/6aeb8545c9b754d6b15be390af4bdff0 to your computer and use it in GitHub Desktop.
Save ardrabczyk/6aeb8545c9b754d6b15be390af4bdff0 to your computer and use it in GitHub Desktop.
Shared object with rpath set
#include <stdio.h>
void foo(void)
{
puts("I'm in foo()");
}
void foo(void);
#include <stdio.h>
void bar(void)
{
puts("I'm in bar()");
}
void bar(void);
#include <stdio.h>
#include <stdlib.h>
#include "lib_two.h"
int main(void)
{
bar();
return EXIT_SUCCESS;
}
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