Hello, all! I created a command line tool that uses dynamic libraries to do different kinds of text processing so you can create a processor in your own tree.
Getting nimble to package it was workable but kind of nontrivial so I thought I'd share. I've got a plugin folder with .nimf files that will expose an interface, and the following .nimble # mytool.nimble version = "0.1.0" author = "Me Myself I" description = "A command line tool with some build in dynamic libraries" license = "MIT" bin = @["mytool"] backend = "c" installExt = @["nim", "nimf", "nims", "so", "dylib", "dll"] requires "nim >= 1.0.0" import os, strutils before build: for file in listFiles( "plugins" ): if file[^5 .. ^1] == ".nimf": echo "Building " & file let cmd = "nim " & backend & " --app:lib" & " -o:" & (DynlibFormat % ("mytool" & lastPathPart(file)[0 .. ^6])) & " " & file echo cmd exec cmd Run So now dynamic lib is built and installed alongside the binary (but not symlinked anywhere). On Windows that's all there is to it, but linux and OSX need some linker options in the main binary so its directory is in the load path # mytool.nims when defined(macosx): switch("passL", "-rpath @loader_path") # researched but untested, can you confirm? elif defined(posix): switch("passL", "-Wl,-rpath,\\$ORIGIN") Run I believe the nim core developers have a very long to do list that is occasionally made even longer by interesting ideas from the commun ity. I am happy to oblige! :) * I would love to have a nim switch that will generate platform specific linker options to load dynlibs from binary's location, like on Windows. This could be considered as default behavior for nim programs. * I would love to have a dynlib build target, analogous to binary, that builds and copies but does not link dynlibs, and a well-known lo cation in the directory structure Thanks for reading! Carlo