On Saturday, 12 November 2022 at 02:45:52 UTC, confuzzled wrote:
It seems that every time I resolve one of these undefined
symbols issues, the compiler finds more. So I keep copying lib
files from locations that are a path, to my working directory
and linking them to my script. Is that the norm? Do I need to
configure DMD somehow to recognize C libraries that are already
in the path?
The linker doesn't care if the libraries are C or D, and the
compiler is only involved in that you can pass flags to the
linker via the compiler command line.
These two things need to be true:
* any link-time dependencies (object files, static libraries,
shared libraries (link libraries on Windows)) need to be passed
to the linker
* the linker needs to know where to find libraries not on the
default search path
The only thing the compiler passes along automatically are the
object files generated from the source and the standard library
it's building a binary. Anything else (including separately
compiled object files), you have to pass along explicitly.
If you aren't explicitly passing any libraries along, then the
linker won't know anything about them. The compiler doesn't know
about them either, so can't pass them along for you.
If you are passing them along but they aren't on the default lib
path, then the linker won't be able to find them.
Based on your description, it sounds like the last case is true
for you. If so, if your libraries are in a common location, you
can pass that path to the linker through dmd via
`-L<linker-specific-flag>`. E.g., on Linux, `-L-L/path/to/libs`.
On Windows, it depends on which linker you're using. For the
Microsoft linker, it's `-L/LIBPATH path\\to\\libs`.
You can also just pass the full path to each library.