Skip to main content
gamedev.net
🔒 Locked

D link errors

Started by Oranda Jan 9, 2007 at 7:07 PM 6 replies 1.4k views
Original Post
Oranda
Oranda
I've recently decided to attempt my next project in D, as I really like the clean nature of the code (I'm a neat freak) and some of the high-level constructs it provides. So far, the compiler works just fine provided I only use the standard libraries. I am, however, having serious issues getting any SDL or OpenGL libraries to work. I tried both Derelict and Andar's packages, but neither of them works. The project will compile just fine, but when I get to the link stage, the linker keeps telling me it can't find most of the function symbols in any of the libraries on my build path. Here are the specs: Ubuntu 6.06 GCC 4.0.3 (I think) DMD 1.0 SDL 1.2 Here is what the linker is spitting out: -------------- Build: Debug in mused --------------- Linking console executable: bin/Debug/mused obj/Debug/hello.o:(.data+0x38): undefined reference to _D3sdl3sdl12__ModuleInfoZ' obj/Debug/hello.o:(.data+0x3c): undefined reference to _D3sdl5video12__ModuleInfoZ' obj/Debug/hello.o:(.data+0x40): undefined reference to _D3sdl6events12__ModuleInfoZ' obj/Debug/hello.o:(.data+0x44): undefined reference to _D3std5error12__ModuleInfoZ' obj/Debug/hello.o:(.data+0x48): undefined reference to _D3sdl5timer12__ModuleInfoZ' obj/Debug/hello.o:(.data+0x4c): undefined reference to _D3sdl8keyboard12__ModuleInfoZ' obj/Debug/hello.o: In function _D11sdl_sample16renderFZv':hello.d:(.gnu.linkonce.t_D11sdl_sample16renderFZv+0xf): undefined reference to SDL_MUSTLOCK' :hello.d:(.gnu.linkonce.t_D11sdl_sample16renderFZv+0xb2): undefined reference to SDL_MUSTLOCK' obj/Debug/hello.o: In function _Dmain':hello.d:(.gnu.linkonce.t_Dmain+0xa1): undefined reference to `_D3sdl6events9SDL_Event6__initZ' collect2: ld returned 1 exit status Process terminated with status 1 (0 minutes, 1 seconds) 0 errors, 0 warnings Has anybody run into problems similar to these?
Aldacron
Aldacron
Quote:
Original post by Oranda
The project will compile just fine, but when I get to the link stage, the linker keeps telling me it can't find most of the function symbols in any of the libraries on my build path.

Here are the specs:
Ubuntu 6.06
GCC 4.0.3 (I think)
DMD 1.0
SDL 1.2

Here is what the linker is spitting out:
-------------- Build: Debug in mused ---------------
Linking console executable: bin/Debug/mused
obj/Debug/hello.o:(.data+0x38): undefined reference to _D3sdl3sdl12__ModuleInfoZ'
obj/Debug/hello.o:(.data+0x3c): undefined reference to
_D3sdl5video12__ModuleInfoZ'
obj/Debug/hello.o:(.data+0x40): undefined reference to _D3sdl6events12__ModuleInfoZ'
obj/Debug/hello.o:(.data+0x44): undefined reference to
_D3std5error12__ModuleInfoZ'
obj/Debug/hello.o:(.data+0x48): undefined reference to _D3sdl5timer12__ModuleInfoZ'
obj/Debug/hello.o:(.data+0x4c): undefined reference to
_D3sdl8keyboard12__ModuleInfoZ'
obj/Debug/hello.o: In function _D11sdl_sample16renderFZv':hello.d:(.gnu.linkonce.t_D11sdl_sample16renderFZv+0xf): undefined reference to SDL_MUSTLOCK'
:hello.d:(.gnu.linkonce.t_D11sdl_sample16renderFZv+0xb2): undefined reference to SDL_MUSTLOCK'
obj/Debug/hello.o: In function
_Dmain':hello.d:(.gnu.linkonce.t_Dmain+0xa1): undefined reference to `_D3sdl6events9SDL_Event6__initZ'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
0 errors, 0 warnings

Has anybody run into problems similar to these?


Is this the output you get when using Derelict or the other bindings? Both? How are you compiling -- directly via dmd/gdc, via bud or DSSS?

I strongly suggest that you direct any Derelict problems you have to the Derelict forums. There are a lot of Derelict users over there, several on Linux, who can help. Derelict is my baby, but I'm not a Linux user myself. When solutions to penguin problems aren't immediately obvious to me, I rely on those good people to solve them. Other D issues should likely go to the DigitalMars.D.learn newsgroup. There aren't many heavy D-ophiles 'round these parts.
TimFang
TimFang
Using dmd.exe, you must input all the d files involved to the command line. You should try the build tools: http://www.dsource.org/projects/build .
I recommend Derelict. :)
Best regards! --http://www.magicgear3d.com
Oranda
Oranda
Thanks guys, I got it to link okay (with derelict), but now I get segmentation faults whenever I run the program. A quick batch of code commenting shows that it dies when I call "SDL_Init(SDL_INIT_VIDEO)". So it's not getting very far in :D. Any ideas on this one?

Aldacron: I was getting those errors with both libraries, with slight variations. Also, I'm compiling using straight dmd. Currently, I only have one source file so I don't need a build program just yet :). And I've forwarded this stuff to the guys at the derelict forums too, but I'll keep people posted here just in case as well.

--edit-- It was linking because libgl.so was in the libraries folder in Code:Blocks. Why that worked, I have no idea, especially since I'm not using in GL code at all yet. Removing it prevents it from linking, and here is the output I get now:
-------------- Build: Debug in mused ---------------
Compiling: hello.d
Linking console executable: bin/Debug/mused
/home/oranda/dmd/lib/libDerelictUtil.a(loader.o): In function
_D8derelict4util6loader24Derelict_UnloadSharedLibFC8derelict4util6loader9SharedLibZv':DerelictUtil/derelict/util/loader.d:
(.gnu.linkonce.t_D8derelict4util6loader24Derelict_UnloadSharedLibFC8derelict4util6loader9SharedLibZv+0x15): undefined reference to
dlclose'
/home/oranda/dmd/lib/libDerelictUtil.a(loader.o): In function _D8derelict4util6loader16Derelict_GetProcFC8derelict4util6loader9SharedLibAaZPv':DerelictUtil/derelict/util/loader.d:
(.gnu.linkonce.t_D8derelict4util6loader16Derelict_GetProcFC8derelict4util6loader9SharedLibAaZPv+0x3f): undefined reference to
dlsym'
/home/oranda/dmd/lib/libDerelictUtil.a(loader.o): In function
_D8derelict4util6loader22Platform_LoadSharedLibFAaZC8derelict4util6loader9SharedLib':DerelictUtil/derelict/util/loader.d:
(.gnu.linkonce.t_D8derelict4util6loader22Platform_LoadSharedLibFAaZC8derelict4util6loader9SharedLib+0x15): undefined reference to
dlopen'
/home/oranda/dmd/lib/libDerelictUtil.a(loader.o): In function _D8derelict4util6loader24Platform_UnloadSharedLibFC8derelict4util6loader9SharedLibZv':DerelictUtil/derelict/util/loader.d:
(.gnu.linkonce.t_D8derelict4util6loader24Platform_UnloadSharedLibFC8derelict4util6loader9SharedLibZv+0xd): undefined reference to
dlclose'
/home/oranda/dmd/lib/libDerelictUtil.a(loader.o): In function _D8derelict4util6loader16Platform_GetProcFC8derelict4util6loader9SharedLibAaZPv':DerelictUtil/derelict/util/loader.d:
(.gnu.linkonce.t_D8derelict4util6loader16Platform_GetProcFC8derelict4util6loader9SharedLibAaZPv+0x17): undefined reference to
dlsym'
/home/oranda/dmd/lib/libDerelictUtil.a(loader.o): In function _D8derelict4util6loader13GenericLoader6unloadMFZv':DerelictUtil/derelict/util/loader.d:
(.gnu.linkonce.t_D8derelict4util6loader13GenericLoader6unloadMFZv+0x24): undefined reference to
dlclose'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 5 seconds)
0 errors, 0 warnings

[Edited by - Oranda on January 9, 2007 7:41:53 PM]
Oranda
Oranda
I didn't get the "Derelict is my baby" bit until I started poking around the forums a bit. So you made derelict, aldacron? Thanks for taking the time to put it all together, man!
Oranda
Oranda
Okay, after much twiddling, I've got it set up and running fine!

Aldacron, I found a "bug" in sdl.d. I suspect that it's just becuase I'm on a linux build of SDL, but the SDL_GetKeyRepeat function doesn't exist in my libraries. A quick comment fixed the problem, but it might be nice to add a version() clause on it so it gets excluded on *nix.

Thanks again for the modules and the help!
Aldacron
Aldacron
Quote:
Original post by Oranda
Okay, after much twiddling, I've got it set up and running fine!


Good news :)

Quote:
Aldacron, I found a "bug" in sdl.d. I suspect that it's just becuase I'm on a linux build of SDL, but the SDL_GetKeyRepeat function doesn't exist in my libraries. A quick comment fixed the problem, but it might be nice to add a version() clause on it so it gets excluded on *nix.


Not a bug. That function was added in SDL 1.2.10. You apparently have an older version on your system. I suggest you upgrade your SDL. In addition, this thread gives an example of how you can avoid this problem and use older versions of SDL (or any Derelict bound lib) using Derelict's Selective Symbol Loading feature. This thread explains how Derelict handles SDL versioning.
Oranda
Oranda
Okay, cool ^^

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.