I am trying to statically link portaudio in Windows. I am using the libportaudio.a file obtained through MSYS2. I had to jump through a few hoops, but I am there, I think, almost.
Please note that I have specified -Xe option to use external linker.
The linker runs with the below options, but errors out, without any specific message. It exits with a non-zero return code (%ERRORLEVEL%) and the executable generate has a size of 0 bytes.
ld.exe -b pei-x86-64 --gc-sections -s --subsystem windows --entry=_WinMainCRTStartup -o D:\pdev\fpc\g_catbell\vc\src\catbell.exe D:\pdev\fpc\g_catbell\vc\src\link.res
However, I have been able to link it successfully if I omit the flag --gc-sections. The executable although not extensively tested, appears to run fine.
I tried to use add --no-gc-sections through Project Options > Compilation and Linknig > Pass options to linker with "-k" option, but the command-line ends up having both --no-gc-sections and --gc-sections, in that order, and the latter overrides the former (I think).
Is there any way to get the flag --gc-sections omitted or overridden through the IDE? Or at least through lazbuild?