digitalmars.D.learn - Linking to static libraries
- Minas (14/14) May 10 2012 I have a static library (libDerelictSDL2.a) in
- Jacob Carlborg (7/19) May 10 2012 Try:
- Minas (5/34) May 10 2012 This works fine!
- Jacob Carlborg (6/8) May 10 2012 Hmm, that wasn't quite right, try this:
- Minas (4/4) May 10 2012 I figured it out, this is the correct:
- H. S. Teoh (6/12) May 10 2012 This is most likely because Derelict uses dynamic loading of modules at
I have a static library (libDerelictSDL2.a) in /usr/lib/Derelict3. What I want to to is just link to that. My code does not use anything from it. My .d file is icy.d. I try to compile using: a) dmd icy.d -I/usr/lib/Derelict3 -L-lDerelictSDL2 b) dmd icy.d -L-I/usr/lib/Derelict3 -L-lDerelictSDL2 c) dmd icy.d -L-lDerelictSDL2 None works, and the error is: /usr/bin/ld: cannot find -lDerelictSDL2 collect2: ld returned 1 exit status --- errorlevel 1 Why can't it find it? I have set the linker's path correctly (I think).
May 10 2012
On 2012-05-10 14:55, Minas wrote:I have a static library (libDerelictSDL2.a) in /usr/lib/Derelict3. What I want to to is just link to that. My code does not use anything from it. My .d file is icy.d. I try to compile using: a) dmd icy.d -I/usr/lib/Derelict3 -L-lDerelictSDL2 b) dmd icy.d -L-I/usr/lib/Derelict3 -L-lDerelictSDL2 c) dmd icy.d -L-lDerelictSDL2 None works, and the error is: /usr/bin/ld: cannot find -lDerelictSDL2 collect2: ld returned 1 exit status --- errorlevel 1 Why can't it find it? I have set the linker's path correctly (I think).Try: $ dmd icy.d -L-L/usr/lib/Derelict3 -L-lDerelictSDL2 You can also supply the library directly: $ dmd icy.d /usr/lib/Derelict3/DerelictSDL2 -- /Jacob Carlborg
May 10 2012
On Thursday, 10 May 2012 at 13:14:36 UTC, Jacob Carlborg wrote:On 2012-05-10 14:55, Minas wrote:Thank you very much!!I have a static library (libDerelictSDL2.a) in /usr/lib/Derelict3. What I want to to is just link to that. My code does not use anything from it. My .d file is icy.d. I try to compile using: a) dmd icy.d -I/usr/lib/Derelict3 -L-lDerelictSDL2 b) dmd icy.d -L-I/usr/lib/Derelict3 -L-lDerelictSDL2 c) dmd icy.d -L-lDerelictSDL2 None works, and the error is: /usr/bin/ld: cannot find -lDerelictSDL2 collect2: ld returned 1 exit status --- errorlevel 1 Why can't it find it? I have set the linker's path correctly (I think).Try: $ dmd icy.d -L-L/usr/lib/Derelict3 -L-lDerelictSDL2 You can also supply the library directly: $ dmd icy.d /usr/lib/Derelict3/DerelictSDL2$ dmd icy.d -L-L/usr/lib/Derelict3 -L-lDerelictSDL2This works fine! $ dmd icy.d /usr/lib/Derelict3/DerelictSDL2 This doesn't because dmd thinks that I'm talking about a .d file.
May 10 2012
On 2012-05-10 15:21, Minas wrote:$ dmd icy.d /usr/lib/Derelict3/DerelictSDL2 This doesn't because dmd thinks that I'm talking about a .d file.Hmm, that wasn't quite right, try this: $ dmd icy.d /usr/lib/Derelict3/libDerelictSDL2.a (Or whatever the full path to the library is) -- /Jacob Carlborg
May 10 2012
I figured it out, this is the correct: -L-L/usr/lib/Derelict2 -L-lDerelictSDL -L-lDerelictUtil -L-ldl I don't know why, but the dl library is needed. Thank you for your help.
May 10 2012
On Thu, May 10, 2012 at 09:00:02PM +0200, Minas wrote:I figured it out, this is the correct: -L-L/usr/lib/Derelict2 -L-lDerelictSDL -L-lDerelictUtil -L-ldl I don't know why, but the dl library is needed. Thank you for your help.This is most likely because Derelict uses dynamic loading of modules at runtime. T -- If the comments and the code disagree, it's likely that *both* are wrong. -- Christopher
May 10 2012