Linking with .dylibs on OSX?

evilrat evilrat666 at gmail.com
Fri Jul 19 21:26:44 PDT 2013


On Friday, 19 July 2013 at 22:30:42 UTC, Jeremy DeHaan wrote:
> On Friday, 19 July 2013 at 19:52:49 UTC, Jeremy DeHaan wrote:
>> On Friday, 19 July 2013 at 18:29:12 UTC, evilrat wrote:
>>> On Friday, 19 July 2013 at 18:19:20 UTC, Jeremy DeHaan wrote:
>>>> I was just curious if DMD supported linking with .dylib 
>>>> files on OSX.
>>>>
>>>> Would one simply do something like this?
>>>>
>>>> "dmd main.d somelib.dylib"
>>>>
>>>> Thanks!
>>>
>>> i don't remember exactly, but if this not work for you try 
>>> something like this
>>> dmd main.d -L-L/path/to/lib.dylib
>>> i think there was a topic on this on wiki
>>
>> That worked! Just one too many -L's though. It ended up being
>>
>> dmd main.d -L/path/to/lib.dylib
>
> I have another question.
>
> Is there a way to specify a search directory and then link to 
> each dylib?
>
> I have someone that I'm trying to help by the way, and I don't 
> have a Mac :P
>
> I was pretty sure that -L-L/path/ seemed to be the way to add 
> the search directory, but if I have a dylib named 
> libsomelib.dylib, would I pass -Lsomelib, -Llibsomelib.dylib, 
> -Lsomelib.dylib, or something else?
>
> Thanks for you help.
>
> P.S.
> Only a guide for compiling and linking on Windows is in the 
> wiki. That should definitely be changed.

with libglfw.dylib it works for me

evilrat$ dmd test.d 
-L-L/Users/evilrat/Documents/prog/glfwbuild/osx/_install/lib 
-L-lglfw

note that first -L is dmd flag to pass linker options, but if you 
linking just single lib you can simply add it as source file like 
this "dmd test.d testlib.a"


More information about the Digitalmars-d-learn mailing list