Linking COFF and OMF
Dmitry Olshansky
dmitry.olsh at gmail.com
Sun Feb 20 13:58:26 PST 2011
I just took a stab at linking together different object formats with
UniLink.
Well, it just works(tm). So I may suggest to anyone having to link with
precompiled COFF static libs on windows to try it out.
For starters I just replaced most of my kernel32.lib, shell32.lib etc
with Microsoft SDK latest COFF import lib variants and
then built and linked winsamp.d from the DMD examples dir. Of course,
that broke optlink linkage.
Then I tried it with static libs, so I produced simplistic static lib
with MinGW gcc:
#include <stdio.h>
int AddInt(int i1, int i2)
{
return i1 + i2;
}
void PrintInt(int a)
{
printf("%d\n",a);
}
and linked with this module:
import std.stdio;
extern(C) int AddInt(int a,int b);
extern(C) int PrintInt(int a);
void main(){
assert(AddInt(3,5) == 8);
PrintInt(42);
writeln("Works?");
}
All passed as expected. (It took renaming lib from *.a to *.lib but
that's it!)
I guess it linked printf with DMC's printf in snn.lib though,
so there might be some problems with foreign RTLs when one goes too far.
P.S. I know I sound like a freaking promoter ;)
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list