gtkd.lib: Error 43: Not a Valid Library File
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jan 26 17:20:49 PST 2016
On Tuesday, 26 January 2016 at 22:30:24 UTC, Enjoys Math wrote:
> On Tuesday, 26 January 2016 at 22:10:42 UTC, Enjoys Math wrote:
>> I get this message either compiling at command line -or- in
>> VisualD.
>>
>> At command line when I add -m64, I get another error:
>>
>>
>> C:\MyProjects\___LIGHTSHOWAPP\___LIGHTSHOWAPP>dmd -m64 main.d
>> -L+gtkd
>> LINK : fatal error LNK1181: cannot open input file '+gtkd.obj'
>> --- errorlevel 1181
>
> Got it to compile and run at command line!
>
> The proper command line is:
> dmd main.d -m64 -Lgtkd.lib
>
> (without +, with .lib)
You appear to have a lack of understanding of linker options. If
I'm wrong, just ignore the rest of this post.
-L tells DMD to pass an argument to the linker. Each linker it
uses accepts options in a different format. The + you used above
has no connection library files on any linker. It's used by
OPTLINK, the default linker DMD uses, to set a path on which to
search for libraries. So, if you had all of your libraries in
C:\mylibs, then you could pass this to dmd:
dmd -L+C:\mylibs main.d -Lgtkd.lib
After compiling main.d, DMD will call optlink with +C\mylibs and,
assuming gtkd.lib is in that directory, optlink will find it.
When you use -m64 (or -m32mscoff), DMD is using the Microsoft
Linker. It will not recognize the +, as it has a different syntax
for specifying the path.
dmd -L/LIBPATH:C:\mylibs main.d -Lgtkd.lib
In both cases, you can actually drop the -L when specifying the
libraries:
dmd -L+C:\mylibs main.d gtkd.lib
dmd -L/LIBPATH:C:\mylibs main.d gtkd.lib
Here, dmd will recognize the .lib extension and will pass the
library names to the linker without the need for -L.
When compiling on other platforms where DMD uses the GNU (or
compatible) linker, it would look like this:
dmd -L-L/path/to/mylibs -L-lgtkd
This linker accepts -L as the switch to specify the path, so -L-L
tells DMD to send that on. It also requires -l (lowercase l) to
specify libraries, so -L-l will do that. The linker will actually
convert the 'gtkd' string to libgtkd.a or libgtkd.so. I can't
recall if passing either, with the extension, on the command line
without -L-l (e.g. libgtkd.a or libgtkd.so) works or not.
More information about the Digitalmars-d-learn
mailing list