Skip to content


How can I supply custom linker parameters?

So, you need to link your program to a custom library or otherwise pass a particular linker option? You can accomplish your goal using the ponyc --linker option.

You’ll need to know what your current linker is. To get it, compile a pony program and pass --verbose 3.

On Linux, MacOS or other Unix-like

Then examine the output. You should see something like:

ld -execute -no_pie -dead_strip -arch x86_64 -macosx_version_min 10.8
  -o ./timer ./timer.o -L"/usr/local/lib/pony/0.9.0-e64bff88c/bin/"
  -L"/usr/local/lib" -lponyrt -lSystem

The ld is the linker command that is usually used on MacOS or Linux. If I wanted to link in the library Foo and needed to pass -lFoo then I would compile my program as:

ponyc --linker="ld -lFoo"

That would change the linker command that ponyc runs to:

ld -lFoo -execute -no_pie -dead_strip -arch x86_64 -macosx_version_min 10.8
  -o ./timer ./timer.o -L"/usr/local/lib/pony/0.9.0-e64bff88c/bin/"
  -L"/usr/local/lib" -lponyrt -lSystem

On Windows

Compiling a pony program with --verbose 3 will produce something like:

cmd /C ""C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\link.exe"
  /DEBUG /NOLOGO /MACHINE:X64 /OUT:.\helloworld.exe .\helloworld.obj
  /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x64"
  /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64"
  /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\lib\x64"
  kernel32.lib msvcrt.lib Ws2_32.lib advapi32.lib vcruntime.lib legacy_stdio_definitions.lib dbghelp.lib ucrt.lib libponyrt.lib "

The path ending in link.exe is the linker that the pony compiler is currently using.

To add options to the link command, I would compile my program as something like:

ponyc --linker="C:\OtherPath\link.exe /LIBPATH:C:\Foo"