-R filename
--just-symbols=filename
Read symbol names and their addresses from filename, but do not relocate it or include it in the output. This allows your output file to refer symbolically to absolute locations of memory defined in other programs. You may use this option more than once.
For example, on my Mac, ld -R libsomething.a
or even gcc -Wl,-R,libsomething.a
doesn't work.
ld normally optimizes for speed over memory usage by caching the symbol tables of input files in memory. This option tells ld to instead optimize for memory usage, by rereading the symbol tables as necessary. This may be required if ld runs out of memory space while linking a large executable.
The ld command, also called the linkage editor or binder, combines object files, archives, and import files into one output object file, resolving external references. It produces an executable object file that can be run.
ldflags , then, stands for linker flags. It is called this because it passes a flag to the underlying Go toolchain linker, cmd/link , that allows you to change the values of imported packages at build time from the command line.
The GNU linker (or GNU ld) is the GNU Project's free software implementation of the Unix command ld. GNU ld runs the linker, which creates an executable file (or a library) from object files created during compilation of a software project.
Since you're talking about "your mac", I assume we are talking about OS X operating systems.
On UNIX-based systems the linker "ld" (with -R option) is used most of the times (see also: ELF).
In contrast OS X Systems use the Mach-O binary format and the tool dyld for linking. OS X doesn't provide the same features for libraries as UNIX does. Try otool -L
on a binary to see where the libraries are expected. You may also want to try setting DYLD_LIBRARY_PATH
(man dyld
) for your binaries but keep in mind the security risk (this could be used to inject code like LD_LIBRARY_PATH
on UNIX-systems).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With