Repository navigation
request for help with compiling a static binary using janet-pm #1947
|
Hello everyone, Here is what I am doing: After answering a couple of questions about the author and the code description, I can happily build a dynamic binary running the following command in the newly created directory: But, if I add and run I have no trouble building a static and stripped binary using the old I'm using the latest janet Is there anyone who can give me some tips on how to fix the error I encountered? |
Replies: 1 comment 3 replies
|
use the (declare-executable
:name "helloworld"
:static true
:lflags ["-s"]
:entry "helloworld/init.janet")the reason is janet-pm looks up libm/librt/libdl on its own and adds them with a |
use the
:staticoption instead of putting-staticin:lflagsthe reason is janet-pm looks up libm/librt/libdl on its own and adds them with a
-Wl,-Bdynamicafter them, so the linker ends up back in dynamic mode. gcc's own-lcat the very end then resolves to libc.so and you get the "attempted static link of dynamic object" errors plus the undefined refs from libm.a. with:static trueit adds-staticitself and switches back to-Wl,-Bstaticafter those libs (thelibsfunction in spork/cc.janet), so libc comes from libc.a as well