FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

linker error

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
[insert witty name]



Joined: 19 Sep 2011
Posts: 2

PostPosted: Tue Aug 07, 2012 8:47 pm    Post subject: linker error Reply with quote

i was about to learn opengl / sdl in D but when trying to compile a simple program i seem to get an error from the linker, when i compile test.d with DMD using the command
Code:
dmd test.d -I/usr/include/x86_64-linux-gnu/dmd/

i get a test.o file (suggests it compiles correctly?)
but i also get an error:
Tried posting the error message on this board but it kept throwing some SQL related tantrum

if i add a -c flag and compile without linking dmd returns 0 suggesting this is definately a problem at the linking stage of things

does anyone know what is causing this?

code for test.d
Code:


import derelict.opengl3.gl3;
import derelict.sdl2.sdl;

void main()
{
   DerelictGL3.load();
   DerelictSDL2.load();
}

Back to top
View user's profile Send private message
BLM768



Joined: 22 Feb 2012
Posts: 13

PostPosted: Tue Aug 07, 2012 9:33 pm    Post subject: Reply with quote

It looks like you're not linking the Derelict libraries into your executable. You can either build Derelict using the instructions on the Derelict3 homepage (https://github.com/aldacron/Derelict3) or use rdmd instead of DMD to build it:

Code:
rdmd test.d -I/usr/include/x86_64-linux-gnu/dmd/


Rdmd automatically compiles all of your code's dependencies, including Derelict, but I haven't figured out how to keep it from stashing the resulting executable in its own cache directory instead of the current directory. It's fine for testing, though, because it will automatically run the program.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Wed Aug 08, 2012 1:20 am    Post subject: Reply with quote

Your question has already mostly been answered. But I would like to add that when compiling with DMD (or GDC or LDC), any library you want to use with your program has to be compiled seperately and linked into your application when you build, or the source modules need to be compiled along side your application. Importing the modules makes the symbols available so that the compiler knows what you're doing, but it doesn't automatically compile the imports (the rdmd tool will do that for you).

As to your command line to link via dmd. First compile Derelict. Then, add the compiled libraries to your command line.

dmd -I/usr/include/x86-64-linux-gnu/dmd -L-L/path/to/DerelictLibs -L-lDerelictGL3 -L-lDerelictSDL2 -L-lDerelictUtil

You always need to link with DerelictUtil when using any Derelict package.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group