The common way to link static lib if no pragma {.compile.} is:

$ gcc -c logic.c
$ ar rvs mylib.a logic.o
$ nim c --passL:mylib.a -r calculator.nim

What is a way to link few libs?

And what is a way to link libs that depend on each other. For example: link libA.a that depends on libB.a and libC.a


2016-01-18 16:48:06
Cam you answer please? 2016-01-20 14:46:58
I'm honestly not sure what the problem is. You know that you can simply use multiple --passL:... options that will simply get passed on to the linker that will process them the same way as for C/C++? Is there anything I'm missing?
2016-01-20 15:46:58

No, I didn't know about multiple --passL:...

Is it write?

nim c --passL:alib.a.blib.a -r calculator.nim

Need to change?

2016-01-20 17:21:26
nim c --passL:alib.a --passL:blib.a -r calculator.nim
2016-01-20 17:48:30

Can anyone point out how to link SDL2 statically? I have tried but none compiles succesfully. Thanks actually I am doing something with https://github.com/yglukhov/nimx/issues/218#issuecomment-302429619

nim c -r --threads:on -d:release --passL:sdl2.a test_nimx.nim
nim c -r --threads:on -d:release --passL:libsdl2.a test_nimx.nim
nim c -r --threads:on -d:release --passL:sdl2 test_nimx.nim
nim c -r --threads:on -d:release --passL:libsdl2 test_nimx.nim

2017-05-18 15:45:30
As far as I understand, you can link to SDL2 statically by passing --define:SDL_Static to the compiler. However, it seems to be broken if you use image or ttf modules:
2017-05-20 20:48:48
Bugs #87 and #88 are fixed. Instead of --define:SDL_Static use --dynlibOverride:SDL2 now. Till SDL2 version 1.2 is released you have to install the version of the repository:
  1. git clone https://github.com/nim-lang/sdl2
  2. cd sdl2
  3. nimble install -y
2017-06-01 17:04:46
Technically, you can also do :
 nimble install sdl2#head
which will ignore release tags and fetch latest master.
2017-06-01 17:55:30