DMD Mac and linking with frameworks

Jacob Carlborg doob at me.com
Sat Mar 14 05:36:10 PDT 2009


Anders F Björklund wrote:
> 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")

I asked that ldc should add this but they said something about a linker 
flag shouldn't be available as a compiler flag.

> 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

I didn't know you could do that. It would be nice if the built in 
pragma(lib, ""); would work like pragma(link, "");



More information about the Digitalmars-d mailing list