I tries to rewrite my project, called progress: call to power (game based on Freeciv) to nim, because I have memory problems (heap overlaps stack, so one function jump outside one's bound).
I tries different approach. First was adding nim.cfg given bellow:
cincludes:../c-files/common
clibdir:../c-files/common
app:lib
output:./libcommon
But it doesn't work.
Next try was by write {.compiletime.} procedure. I use walkDir from us module with pattern *.c, but I cannot use compile with variable, because this variable doesn't been known at compile time (I called my function from normal code, so probably there's a problem - is there any way to call it at compile time?)
(heap overlaps stack, so one function jump outside one's bound).
That seems very improbably. It's more likely that you have a stack overflow and while writing a stack variable you also overwrite the return instructions of your function.
Is your code open-source?
If you compile your code with:
I got first step forward. I will update this thread for any other nim/nimble beginners.
What I doing wrong? First impression I must put different configuration of compiler with relating submodules to separate directories was good, but I don't known how to order nimble to build more modules. My mind just skip bin property in .nimble file was array. I added path to other modules relative to srcDir. Also I must repair syntax of nimble file. Missfortunately, path was os-dependent. I attach files here:
Package
version = "0.0.1" author = "Sławomir Lach" description = "Nimble version of postęp - game based on Freeciv" license = "GPL-2.0" srcDir = "src" installExt = @["nim"] bin = @["postep", "posteppkg/common/libcommon"]
Dependencies
requires "nim >= 1.0.0"
--gc="refc"
I just discovered NIM doesn't append a file extension to my library. -l linker argument gives linker name by omitting lib prefix and so extension. These are append automatically and linker will search lib names by matching it to result of mentioned operations.
How to force nimc to generate file with .so extension?