DMD Mac and linking with frameworks

Anders F Björklund afb at algonet.se
Fri Mar 13 05:27:17 PDT 2009


Jacob Carlborg wrote:

>> Seems it needs the -L flag on each: dmd -L-framework -LCarbon main.d
>>
>> Because -Xlinker is being used, "-Wl,-framework,Carbon" doesn't work.
>>
> It worked. Thanks. It's a little annoying that all three compilers have 
> to use different commands for this.

Yeah, it's somewhat annoying. Versions have the same problem, too:
     dmd -version=foo
     gdc -fversion=foo
     ldc -d-version=foo

Of course one can use a build tool or development environment to add
those, or use the gdmd and ldmd wrappers which might not work for libs.
(it would however be nice if DMD for Mac OS X could be taught to accept
the most straightforward syntax for it, i.e. "dmd -framework Carbon")

The most intriguing part was trying to link frameworks with "pragma",
where the build tool will automatically add a friendly "-l" for you...
The workaround is to include a library that is always available/used,
and then append the real framework linker flags after that library:

version (build) { pragma(link, "System -framework Carbon"); }

--anders



More information about the Digitalmars-d mailing list