digitalmars.D - DMD Mac and linking with frameworks
- Jacob Carlborg (10/10) Mar 09 2009 If I understand things correct dmd uses gcc to do the linking on linux
- Walter Bright (2/2) Mar 09 2009 You can use the -v switch to dmd which will show the linker command line...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/8) Mar 09 2009 Seems it needs the -L flag on each: dmd -L-framework -LCarbon main.d
- Jacob Carlborg (3/15) Mar 12 2009 It worked. Thanks. It's a little annoying that all three compilers have
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (15/21) Mar 13 2009 Yeah, it's somewhat annoying. Versions have the same problem, too:
- Jacob Carlborg (5/31) Mar 14 2009 I asked that ldc should add this but they said something about a linker
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (9/23) Mar 15 2009 Me neither, it was more of a desperate attempt to try to convert the
- Jarrett Billingsley (2/12) Mar 09 2009 Just a shot, but -L"-framework Carbon" ?
If I understand things correct dmd uses gcc to do the linking on linux and osx, therefore I should be able to link against frameworks on osx. GDC/GCC uses the compiler flag "-framework Carbon" and the passes the same flag to the linker. LDC/LLVM uses the linker flag "-framework=Carbon" which I can pass to the linker using "-L". But I can't figure out how to do that with DMD. The problem is if compile like this for example: "dmd -L-framework Carbon main.d" dmd complains that it can't find Carbon.d. It seems that it takes everything as a D source file if it doesn't recognize it as a compiler switch.
Mar 09 2009
You can use the -v switch to dmd which will show the linker command line it tries.
Mar 09 2009
Jacob Carlborg wrote:The problem is if compile like this for example: "dmd -L-framework Carbon main.d" dmd complains that it can't find Carbon.d. It seems that it takes everything as a D source file if it doesn't recognize it as a compiler switch.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. --anders
Mar 09 2009
Anders F Björklund wrote:Jacob Carlborg wrote:It worked. Thanks. It's a little annoying that all three compilers have to use different commands for this.The problem is if compile like this for example: "dmd -L-framework Carbon main.d" dmd complains that it can't find Carbon.d. It seems that it takes everything as a D source file if it doesn't recognize it as a compiler switch.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. --anders
Mar 12 2009
Jacob Carlborg wrote: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"); } --andersSeems 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.
Mar 13 2009
Anders F Björklund wrote:Jacob Carlborg wrote:I asked that ldc should add this but they said something about a linker flag shouldn't be available as a compiler flag.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")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.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"); } --andersI didn't know you could do that. It would be nice if the built in pragma(lib, ""); would work like pragma(link, "");
Mar 14 2009
Jacob Carlborg wrote:I guess that prefixing -L to the linker flags is the way to go then.(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.Me neither, it was more of a desperate attempt to try to convert the wx-config --libs into something that bud/build could make use of... Naturally it failed anyway, due to some weird linking order issues, but at least it tried - and wx.libs looks reasonable enough to me. Don't think pragma(lib) ever worked here, but saw it in D 1.037 Think it was http://d.puremagic.com/issues/show_bug.cgi?id=1690 --andersThe 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"); }I didn't know you could do that. It would be nice if the built in pragma(lib, ""); would work like pragma(link, "");
Mar 15 2009
On Mon, Mar 9, 2009 at 4:36 PM, Jacob Carlborg <doob me.com> wrote:If I understand things correct dmd uses gcc to do the linking on linux and osx, therefore I should be able to link against frameworks on osx. GDC/GCC uses the compiler flag "-framework Carbon" and the passes the same flag to the linker. LDC/LLVM uses the linker flag "-framework=Carbon" which I can pass to the linker using "-L". But I can't figure out how to do that with DMD. The problem is if compile like this for example: "dmd -L-framework Carbon main.d" dmd complains that it can't find Carbon.d. It seems that it takes everything as a D source file if it doesn't recognize it as a compiler switch.Just a shot, but -L"-framework Carbon" ?
Mar 09 2009