diff --git a/compiler/commands.nim b/compiler/commands.nim index a71dae9d96da0..6e8568ffe7ec6 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -803,7 +803,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "clib": expectArg(conf, switch, arg, pass, info) if pass in {passCmd2, passPP}: - conf.cLinkedLibs.add processPath(conf, arg, info).string + conf.cLinkedLibs.add arg of "header": if conf != nil: conf.headerFile = arg incl(conf.globalOptions, optGenIndex) diff --git a/tests/compiler/samplelib.nim b/tests/compiler/samplelib.nim new file mode 100644 index 0000000000000..c709717220ae9 --- /dev/null +++ b/tests/compiler/samplelib.nim @@ -0,0 +1,2 @@ +# Sample library used by tcmdlineclib.nim +proc test(): int {.cdecl, exportc, dynlib.} = 123 diff --git a/tests/compiler/tcmdlineclib.nim b/tests/compiler/tcmdlineclib.nim new file mode 100644 index 0000000000000..c06d6f1034360 --- /dev/null +++ b/tests/compiler/tcmdlineclib.nim @@ -0,0 +1,3 @@ +proc test(): int {.importc, cdecl.} + +doAssert test() == 123 diff --git a/tests/compiler/tcmdlineclib.nims b/tests/compiler/tcmdlineclib.nims new file mode 100644 index 0000000000000..f7899d92e7c93 --- /dev/null +++ b/tests/compiler/tcmdlineclib.nims @@ -0,0 +1,10 @@ +import os + +selfExec "c --app:lib " & (projectDir() / "samplelib.nim") +switch("clibdir", projectDir()) +--clib:samplelib + +# Make test executable can load sample shared library. +# `-rpath` option doesn't work and ignored on Windows. +# But the dll file in same directory as executable file is loaded. +switch("passL", "-Wl,-rpath," & projectDir())