I'm trying to statically link the cilk library to my program, in order to be able to run the executable on environments that don't have the cilk libraries installed (since it is not so common).
Here is the best I could come up with:
cilkc -Ofast -Wextra -pedantic -fwhole-program -flto -msse4.2 -m64 -lm -mtune=generic -funroll-loops -finline-functions -ffast-math -lpthread -lz -DUSE_GCC -Wc,-std=c99 -Wc,-pipe -DUSE_FILE32API /usr/local/lib/libcilk.a /usr/local/lib/cilk/libcilkrt0.a src/all.c src/CilkSearch.cilk
As stated, i manually link libcilk.a and libcilkrt0.a to prevent gcc to link to the shared libraries. This makes the program size increase from 266Kb to 344Kb, which makes me think the static linking succeeded.
Sadly, though, when i inspect with otool the dependencies of my executable, i get:
bin/hayabusa:
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/local/lib/libcilk.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/opt/local/lib/gcc47/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
I understand zlib and gcc, which i didn't statically link yet. But why is the libcilk.0.dylib dependency still there if i manually linked to libcilk.a?
I also actually try to run the program on another computer, but at startup the program terminates complaining that /usr/local/lib/libcilk.0.dylib cannot be loaded.
So my question is, explicitly specifying the .a to gcc is not enough to drop the specified library dependency? What else should I do to have my libcilk linked statically and not loaded at runtime?
I already know about the -static option, but i don't want every library including system ones to be statically linked, I only want the cilk library to be statically linked.
Is this possible at all?