optlink options to reduce file size?

simendsjo simendsjo at gmail.com
Wed Jul 27 15:50:36 PDT 2011


On 28.07.2011 00:30, Dmitry Olshansky wrote:
> On 28.07.2011 2:03, simendsjo wrote:
>> On 27.07.2011 23:00, Dmitry Olshansky wrote:
>>> On 27.07.2011 21:16, simendsjo wrote:
>>>> On 27.07.2011 15:45, Dmitry Olshansky wrote:
>>>>> On 27.07.2011 15:21, simendsjo wrote:
>>>>>> A simple hello world like dfl application takes 1.2mb. Upx does a
>>>>>> great job packing this to 200k, but I wonder if there is a way to
>>>>>> make
>>>>>> optlink generate smaller executables?
>>>>>>
>>>>>> I couldn't find a way to get help on the numerous options in optlink,
>>>>>> and the help page at digitalmars doesn't list them either.
>>>>> I've noticed around two times smaller exes when linked with
>>>>> unilink. So
>>>>> if you don't like packing you may try it:
>>>>> ftp://ftp.styx.cabel.net/pub/UniLink/ulnb0319.zip
>>>>> <ftp://ftp.styx.cabel.net/pub/UniLink/>
>>>>> just make sure you configured it correctly (should be straightforward,
>>>>> there are examples)
>>>>>
>>>>
>>>> Thanks. Any idea if unilink works with libraries linked with optlink?
>>>> I get "Error: Invalid library file (3) 'some optlink.lib'"
>>>
>>> For what it's worth any D2 app uses phobos.lib and obviously that
>>> worked. Not that it was linked, library is a sort of a package with obj
>>> files. Also check if this is in fact library it might very well be
>>> renamed executable in which case 2 first bytes of file are 'MZ'.
>>> It should work with both OMF (DMC, old MS VC++ etc.) and COFF (MinGW,
>>> modern MS C++ etc.) libraries.
>>>
>>
>> Tried a minimal sample using only phobos. Gave me another error:
>> Error: Unresolved external '__acrtused_con' referenced from 't.obj'
>> I downloaded the entire dm compiler and added snn.lib which solved the
>> problem.
>>
>
> Yes, I should have mentioned it. Btw snn.lib lives in dmd2\windows\lib
>
>> I'm still getting linker errors on the old file though.
>>
>> > dmd t3 dfl.lib
>> No problem.
>>
>> > ulink.exe -Go -Tpe t3.obj,t3.exe,,dfl.lib
>> UniLink v1.07 [beta] (build 3.19)
>> Error: Invalid library file (3) 'c:\d\ext\dwin\lib\dfl.lib'
> Hm.. you might try to link with just object files then. Still it's
> weird, could be a bug in unilink.
> If you inclined that this is the case, send sample obj and lib to
> developers with some info ulink(at)styx.cabel.net
> Judging by my experience, sending source code in addition to obj files
> is appreciated.
>

Could be a bug, but it's most likely my bad as this is the first time I 
try unilink.
Could someone else on windows verify that dfl cannot be linked with unilink?


More information about the Digitalmars-d-learn mailing list