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

Linker errors all over the place
Goto page 1, 2  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
kakbarnf



Joined: 10 Apr 2007
Posts: 3

PostPosted: Tue Apr 10, 2007 9:51 am    Post subject: Linker errors all over the place Reply with quote

Hello. I've been trying for ages to compile a test program with Derelict, but with no luck. Here is what I'm trying to compile:

Code:

import derelict.opengl.gl;

void main()
{
}


I installed Derelict with
Code:
dmd -run install.d ~/dmd/src/ext
without building the libs, just like DMedia suggested (though I've tried it with the libs too and it still doesn't work).

The command I'm using is

Code:
bud test.d -I~/dmd/src/ext -UMB -L-ldl


And the output is

Code:

test.o:(.data+0x30): undefined reference to `_D8derelict6opengl2gl12__ModuleInfoZ'
collect2: ld returned 1 exit status


I've tried just about everything I can think of, but nothing works.
Back to top
View user's profile Send private message
aldacron



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

PostPosted: Tue Apr 10, 2007 6:48 pm    Post subject: Reply with quote

This is a linker error, which means that Derelict is being found and compiled fine. It's apparently breaking down when it tries to link the resultant object files. So you're OK as far as compilation goes.

You didn't say it explicitly, but based on the info you gave I assume you are using DMD on Linux. If that is the case, drop the -UMB and try passing -op instead.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
kakbarnf



Joined: 10 Apr 2007
Posts: 3

PostPosted: Wed Apr 11, 2007 6:54 am    Post subject: Reply with quote

That's right, I should have said I'm on Linux. DMD iis version 1.010, if it makes a difference.

Anyway, -op instead of -UMB doesn't fix things, I just get similar errors:

Code:

$ bud test.d -I~/dmd/src/ext -op -L-ldl
/home/robin//dmd/src/ext/derelict/opengl/gl.o:(.data+0x160): undefined reference to `_D8derelict6opengl3glx12__ModuleInfoZ'
/home/robin//dmd/src/ext/derelict/opengl/gl.o: In function `_D8derelict6opengl2gl7loadAllFC8derelict4util6loader9SharedLibZv':
/home/robin//dmd/src/ext/derelict/opengl/gl.d:(.gnu.linkonce.t_D8derelict6opengl2gl7loadAllFC8derelict4util6loader9SharedLibZv+0xb): undefined reference to `loadPlatformGL'
/home/robin//dmd/src/ext/derelict/opengl/gl.o: In function `_D8derelict6opengl2gl10DerelictGL15hasValidContextFZb':
/home/robin//dmd/src/ext/derelict/opengl/gl.d:(.gnu.linkonce.t_D8derelict6opengl2gl10DerelictGL15hasValidContextFZb+0x5): undefined reference to `glXGetCurrentContext'
collect2: ld returned 1 exit status


With -UMB I'm now getting (though I haven't changed anything):

Code:

$ bud test.d -I~/dmd/src/ext -UMB -L-ldl
gl.o:(.data+0x160): undefined reference to `_D8derelict6opengl3glx12__ModuleInfoZ'
gl.o: In function `_D8derelict6opengl2gl7loadAllFC8derelict4util6loader9SharedLibZv':
/home/robin//dmd/src/ext/derelict/opengl/gl.d:(.gnu.linkonce.t_D8derelict6opengl2gl7loadAllFC8derelict4util6loader9SharedLibZv+0xb): undefined reference to `loadPlatformGL'
gl.o: In function `_D8derelict6opengl2gl10DerelictGL15hasValidContextFZb':
/home/robin//dmd/src/ext/derelict/opengl/gl.d:(.gnu.linkonce.t_D8derelict6opengl2gl10DerelictGL15hasValidContextFZb+0x5): undefined reference to `glXGetCurrentContext'
collect2: ld returned 1 exit status


I don't want to seem like I'm just copy and pasting my problems to the forum and getting someone else to solve them, but I really don't know where to start with linker errors. Is there maybe something else I need to link to? I'm surprised I haven't been told to link to OpenGL itself, though I wouldn't know how.
Back to top
View user's profile Send private message
aldacron



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

PostPosted: Wed Apr 11, 2007 7:47 pm    Post subject: Reply with quote

kakbarnf wrote:
I don't want to seem like I'm just copy and pasting my problems to the forum and getting someone else to solve them, but I really don't know where to start with linker errors.


Unfortunately, in this particular case I have no idea what's causing your problem. I've noticed similar errors when using Bud with a DMD environment configured for Tango, but there's enough difference in this case that I assume that's not the problem here (i.e., you likely don't have Tango configured).

Quote:
Is there maybe something else I need to link to? I'm surprised I haven't been told to link to OpenGL itself, though I wouldn't know how.


No, you shouldn't need to link to anything else. The reason you don't have to link with OpenGL is because Derelict loads the shared library manually. That's why you link with libdl and call DerelictGL.load.

I've not encountered this sort of problem on Linux before. When I have time later, I'll see if I can reproduce it. But for now, two things I can think of off the top of my head:

* give a try with Rebuild in place of Bud. It's a similar tool, but sometimes works when building with Bud fails. If Rebuild handles it successfully, then perhaps it's an issue with Bud. Otherwise, it's anyone's guess.

* replace '-I~/dmd/src/ext' with the expanded path ('-I/home/robin/dmd/src/ext') and see if that makes a difference. The path in the output looks odd to me with the two slashes (such as /home/robin//dmd/src/ext/derelict/opengl/gl.o). I don't think I've ever seen that before. This is a wild guess, though.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
kakbarnf



Joined: 10 Apr 2007
Posts: 3

PostPosted: Fri Apr 13, 2007 8:11 am    Post subject: Reply with quote

Once I got Rebuild up and running the problem disappeared! You were really helpful. Thanks enormously.
Back to top
View user's profile Send private message
aldacron



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

PostPosted: Fri Apr 13, 2007 10:22 am    Post subject: Reply with quote

I'm glad you were able to sort it out.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
stealth



Joined: 06 May 2007
Posts: 9

PostPosted: Sun May 06, 2007 10:03 am    Post subject: Reply with quote

Hi
I also have such linker errors, but when I use rebuild instead of bud, im still having them
Could someone pls help me?
Back to top
View user's profile Send private message
aldacron



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

PostPosted: Sun May 06, 2007 12:05 pm    Post subject: Reply with quote

Mauer wrote:
Hi
I also have such linker errors, but when I use rebuild instead of bud, im still having them
Could someone pls help me?


It would help greatly if you give the following information:

Which compiler are you using with Rebuild: DMD or GDC?
Which platform are you on?
Are you using Phobos or Tango?

Also post the errors you are seeing.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
stealth



Joined: 06 May 2007
Posts: 9

PostPosted: Sun May 06, 2007 1:46 pm    Post subject: Reply with quote

Im using DMD on Linux.
And im using Phobos, but those errors are only accuring if i import derelict.

I get such errors as kakbarnf, with bud and rebuild:
Sry i cant post them because then there are mysql errors, maybe cause the text is too long Laughing

Edit
It didnt work because there was a language specific letter in it. Here we go:
Code:
$ rebuild example.d
gcc ./_example.o ./derelict.opengl.gl.o ./derelict.opengl.gltypes.o ./derelict.opengl.glfuncs.o ./derelict.util.loader.o ./derelict.util.exception.o ./derelict.util.wrapper.o ./nmd_gcstats.o ./derelict.opengl.gl12.o ./derelict.opengl.gl13.o ./derelict.opengl.gl14.o ./derelict.opengl.gl15.o ./derelict.opengl.gl20.o ./derelict.opengl.gl21.o ./derelict.opengl.glx.o -o example -m32 -lphobos -lpthread -lm -Xlinker --start-group -Xlinker -lphobos -Xlinker -L/usr/local/bin/../lib -Xlinker -L/usr/local/bin/../lib
./derelict.util.loader.o: In function `_D8derelict4util6loader22Platform_LoadSharedLibFAaZC8derelict4util6loader9SharedLib':
derelict/util/loader.d:(.gnu.linkonce.t_D8derelict4util6loader22Platform_LoadSharedLibFAaZC8derelict4util6loader9SharedLib+0x15): undefined reference to `dlopen'
./derelict.util.loader.o: In function `_D8derelict4util6loader24Platform_UnloadSharedLibFC8derelict4util6loader9SharedLibZv':
derelict/util/loader.d:(.gnu.linkonce.t_D8derelict4util6loader24Platform_UnloadSharedLibFC8derelict4util6loader9SharedLibZv+0xf): undefined reference to `dlclose'
./derelict.util.loader.o: In function `_D8derelict4util6loader16Platform_GetProcFC8derelict4util6loader9SharedLibAaZPv':
derelict/util/loader.d:(.gnu.linkonce.t_D8derelict4util6loader16Platform_GetProcFC8derelict4util6loader9SharedLibAaZPv+0x19): undefined reference to `dlsym'
collect2: ld gab 1 als Ende-Status zur(ü)ck
--- errorlevel 1
Back to top
View user's profile Send private message
aldacron



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

PostPosted: Sun May 06, 2007 5:55 pm    Post subject: Reply with quote

On Linux, you need to link with libdl for all derelict applications. Derelict uses it internally to load the shared libraries and neither DMD nor GDC link it by default.

EDIT: This was already mentioned in the documentation on loading (loading.html). But since it crops up from time-to-time, I've added a new section to the documentation front page, titled 'Dependencies'. Maybe more people will see it now. If not, I can now mock them and say it's in the docs *twice*!
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
stealth



Joined: 06 May 2007
Posts: 9

PostPosted: Mon May 07, 2007 5:36 am    Post subject: Reply with quote

Hmm i thought i already tried it with linking ldl but now i tried it again and it works, thx
Back to top
View user's profile Send private message
stealthnsk



Joined: 09 May 2007
Posts: 5
Location: Russia, Novosibirsk

PostPosted: Wed May 09, 2007 11:15 am    Post subject: Reply with quote

Bringing my question here. I got the following error compiling simple application with BUD:

Error 42: Symbol Undefined _D8derelict6opengl2gl10DerelictGL4loadFAaZv

OS: XP
Core Lib: Tango
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Sun May 20, 2007 4:42 pm    Post subject: Reply with quote

I just had the glXGetCurrentContext -related linker error. It turns out that Bu[il]d freaks out on the version statement, behind which import derelict.glx is hidden. The trick to fix it, is to add the glx.d file manually to the compile command. Works like a charm!
Back to top
View user's profile Send private message MSN Messenger
Will



Joined: 15 May 2007
Posts: 3

PostPosted: Mon May 28, 2007 2:30 pm    Post subject: Reply with quote

Hi,

I've got the same problem,
it compile without problem the exemple code (from here)

but when linking time come :

Quote:
compile dmd -c sample.d c:\Compiler\D\dmd\bin\..\src\phobos\gcstats.d -Ic:/Co
mpiler/D/rebuild-0.65-win/bin\..\include\d -IC:\Compiler\D\dmd\src\ext\ -Ic:\C
ompiler\D\dmd\bin\..\src\phobos -od.
rename .\sample.obj to .\nmd_sample.obj
rename .\gcstats.obj to .\nmd_gcstats.obj
link dmd gdi32.lib .\nmd_sample.obj .\nmd_gcstats.obj -ofsample.exe
c:\Compiler\D\dmd\bin\..\..\dm\bin\link.exe .\nmd_sample+.\nmd_gcstats,sample.ex
e,,gdi32.lib+user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved

.\nmd_sample.obj(nmd_sample)
Error 42: Symbol Undefined _D8derelict6opengl2gl10DerelictGL4loadFAaZv
--- errorlevel 1


Same result with Bud

Arrow derelict objs files don't have to appear in linking line ?

DMD : v1.012
buid : v3.04(2514)
rebuild : version 0.65 (based on DMD 1.013)
OS : XP
Back to top
View user's profile Send private message
aldacron



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

PostPosted: Mon May 28, 2007 6:09 pm    Post subject: Reply with quote

I assume all of the output you posted is from a verbose run of Rebuild. It would be helpful if you could post the actual command line you use. Also, are you using Tango or Phobos?

Will wrote:

Arrow derelict objs files don't have to appear in linking line ?


When using Rebuild or Bud, they automatically pass the compiled Derelict object files to the linker. If that's not happening, then something is wrong with your configuration.

Note to future posters: please, please, please start a new topic when you have a problem. There are three different types of linker errors posted in this thread that all have different solutions. The only thing they have in common is that they are all linker errors. They are not all the same. It makes the problems and the solutions more difficult to follow. After we get Will's problem solved, I'm locking the thread. Until then, don't post new linker errors here!
_________________
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   This topic is locked: you cannot edit posts or make replies.     Forum Index -> Derelict All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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