I am using mingw gcc and msys to build a number of GNU utilities. In the past, I have had a lot of problems caused by different executables requiring different versions of libiconv, so to avoid the issue I wanted to link iconv statically into the executables.
I have built libiconv using mingw and msys with configure --enable-static. This creates both the DLL, the .dll.a import library and the plain .a static library.
However, when I try to build another program which links with a simple -liconv, I get the DLL linked in. I assume that ld is for some reason preferring the import library over the static library (not a bad choice in general, this is a special case).
How can I ensure that programs I build are statically linked? One obvious approach is simply to remove the .dll.a file while doing the build. That is probably the simplest option, but I am curious - is there a linker flag I can set (via something like LDFLAGS) to force iconv to be loaded statically (ideally, without affecting other libraries, but at a pinch I'd be OK with loading all libraries statically)