nfltk icon indicating copy to clipboard operation
nfltk copied to clipboard

Static link

Open Peter2121 opened this issue 6 years ago • 2 comments

Hi, By default FLTK library is linked dynamically. How can I create a statically linked image of my nim program? Thanks

Peter2121 avatar Oct 13 '19 19:10 Peter2121

Depending on the environment, change the name of the library the module links to and possibly add some C defines so the FLTK headers know you are doing a static build.

https://github.com/Skrylar/nfltk/blob/d1b497d74a3be64a11e8b819a482022c611bcfe0/fltk.nim#L2

Skrylar avatar Oct 15 '19 03:10 Skrylar

I am on Mac OS X. I tried to replace Line 2 in fltk.nim with: {.passL: "/usr/local/Cellar/fltk/1.3.5/lib/libfltk.a -lpthread -framework Cocoa".} (It is the options returned by fltk-config --ldstaticflags command) No luck, the linker says:

duplicate symbol _FL_NORMAL_SIZE in:
    /Users/peter/.cache/nim/testpeter_d/@[email protected]
    /usr/local/Cellar/fltk/1.3.5/lib/libfltk.a(Fl_Widget.o)
ld: 1 duplicate symbol for architecture x86_64

Sure, the symbol is defined in both files. I tried to add --dynlibOverrideAll to build command, but it changes nothing.

Peter2121 avatar Oct 15 '19 09:10 Peter2121