[LINUX] Ignore soname when linking (could not)


int op(int x,int y){return x+y;}


int op(int x,int y);
int gateway(){return op(123,456);}


#include <stdio.h>
int gateway();
int main(){


mkdir -p mul
cat func.c | gcc -O2 -s -shared -Wl,-soname,func.so -o func.so -xc -
cat func.c | sed 's/+/*/' | gcc -O2 -s -shared -Wl,-soname,func.so -o mul/func.so -xc -
#patchelf --set-soname '' mul/func.so
gcc -O2 -s -shared -o gateway.so gateway.c $PWD/mul/func.so
#patchelf --replace-needed func.so $PWD/mul/func.so gateway.so
gcc -O2 -s main.c gateway.so

In this situation, I want a.out to output 56088 (instead of 579). ** However, the compile options of func.so cannot be changed. ** **

After some trial and error, I had to use patchelf (comment out one of the two patchelfs).

Recommended Posts

Ignore soname when linking (could not)
OS Error: could not find or load spatialindex_c-64.dll when importing geopandas