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

Linker errors

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
Deewiant



Joined: 26 Dec 2005
Posts: 21
Location: Finland

PostPosted: Wed Jan 18, 2006 9:54 am    Post subject: Linker errors Reply with quote

I'm doing this for the fourth time now:
Code:
C:\dmd>svn co http://svn.dsource.org/projects/derelict/trunk/
(...)
Checked out revision 128.

C:\dmd>cd trunk

C:\dmd\trunk>buildconfig
C:\dmd\trunk>buildme release
(...)
Digital Mars Librarian complete.

C:\dmd\trunk>copy lib\*.lib ..\lib
(...)
13 file(s) copied.

(use Explorer to copy all the .d files from C:\dmd\trunk\DerelictWhatever\derelict\whatever to C:\dmd\src\derelict\whatever)

C:\dmd\trunk>cd DerelictSDL

C:\dmd\trunk\DerelictSDL>dmd example.d

Shocked Bam! Enough linker errors to fill up my console's 50-line buffer. A snippet of the first and last:
Code:
C:\dmd\bin\..\..\dm\bin\link.exe example,,,user32+kernel32/noi;

OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved
   
example.obj(example)
 Error 42: Symbol Undefined __Class_8derelict4util9exception26SharedLibProcLoadException
example.obj(example)
 Error 42: Symbol Undefined __Class_8derelict4util9exception22SharedLibLoadException
C:\dmd\bin\..\lib\derelictSDL.lib(sdl)
 Error 42: Symbol Undefined _SDL_WM_GetCaption
C:\dmd\bin\..\lib\derelictSDL.lib(sdl)
 Error 42: Symbol Undefined _SDL_WM_SetIcon
C:\dmd\bin\..\lib\derelictSDL.lib(sdl)
 Error 42: Symbol Undefined _SDL_WM_IconifyWindow
C:\dmd\bin\..\lib\derelictSDL.lib(sdl)
 Error 42: Symbol Undefined _SDL_WM_ToggleFullScreen

(...)

C:\dmd\bin\..\lib\derelictSDL.lib(sdl)
 Error 42: Symbol Undefined _SDL_LoadWAV_RW
C:\dmd\bin\..\lib\derelictUtil.lib(loader)
 Error 42: Symbol Undefined _D8derelict4util9exception22SharedLibLoadException5_ctorFAaZC8derelict4util9exception22SharedLibLoadException
C:\dmd\bin\..\lib\derelictUtil.lib(loader)
 Error 42: Symbol Undefined _D8derelict4util9exception26Derelict_HandleMissingProcFAaAaZv
C:\dmd\bin\..\lib\derelictUtil.lib(loader)
 Error 42: Symbol Undefined _D8derelict4util9exception31InvalidSharedLibHandleException5_ctorFAaZC8derelict4util9exception31InvalidSharedLibHandleException
C:\dmd\bin\..\lib\derelictUtil.lib(loader)
 Error 42: Symbol Undefined __Class_8derelict4util9exception31InvalidSharedLibHandleException
--- errorlevel 189

What am I doing wrong, or what's wrong with my system? Confused

This all started from me wanting to try out DerelictIL, finding that "svn up" refused to work (if I remember correctly, it was happy to give me "Checked out revision 118." - a bit old for me), and therefore deciding to just delete my working Derelict files and start from scratch with a checkout. Before this, my SDL programs compiled and linked fine; now, with Derelict updated, nothing does.

What's interesting is that the libraries themselves seem to cause the errors: if I comment out the pragmas in example.d which link in the Derelict libraries, I only get undefined symbols for what's referred to in example.d - DerelictSDL_Load(), SharedLibLoadException, SharedLibProcLoadException.

So it seems to me that the libraries aren't getting properly compiled. Any ideas why not?
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Wed Jan 18, 2006 1:20 pm    Post subject: Re: Linker errors Reply with quote

Deewiant wrote:

Shocked Bam! Enough linker errors to fill up my console's 50-line buffer.


While I haven't a clue what is going wrong with your compile, I do have a trick that might help you with your console, and thus see a lot more of the compiler's output w/o having to pipe it somewhere.

Provided you're under Windows, using a console window (cmd.exe), you can always do this:

Code:
mode con: lines=999 cols=120


Or whatever dimensions make you happy. Just resize your window so it fits comfortably on your desktop and you're good to go.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Crispy



Joined: 26 Nov 2005
Posts: 67

PostPosted: Wed Jan 18, 2006 3:18 pm    Post subject: Reply with quote

Useful tip, pragma, I'll have to remember that one!

As for the linker error, perhaps it wants .lib files and isn't finding them? Try rebuilding all of Derelict. Also try telling it to look for library files in C:\dmd\trunk\lib.

And finally, I really recommend that you use the Build utility. It makes things much easier. To give you an idea, this is my (probably overly-long) command to build my current project in debug mode with warnings and unit tests (this is in a .bat file so I don't have to retype it all the time):

build.exe main.d -debug -g -w -unittest -I"D:\D\derelict\DerelictSDL" -I"D:\D\derelict\DerelictUtil" -I"D:\D\derelict\DerelictGL" -I"D:\D\derelict\DerelictSDLttf" -I"D:\D\derelict\DerelictSDLNet" -I"D:\D\derelict\DerelictSDLImage" -silent

In your case, replace D:\D\derelict with C:\dmd\trunk. There are probably much better ways to include everything than this, but this works. Also note that I'm including lots of other libraries as well as SDL, which you probably won't need.
Back to top
View user's profile Send private message
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Wed Jan 18, 2006 10:19 pm    Post subject: Re: Linker errors Reply with quote

pragma wrote:
Deewiant wrote:

Shocked Bam! Enough linker errors to fill up my console's 50-line buffer.


While I haven't a clue what is going wrong with your compile, I do have a trick that might help you with your console, and thus see a lot more of the compiler's output w/o having to pipe it somewhere.

Provided you're under Windows, using a console window (cmd.exe), you can always do this:

Code:
mode con: lines=999 cols=120


Or whatever dimensions make you happy. Just resize your window so it fits comfortably on your desktop and you're good to go.


Or click on the icon in the upper left, choose properties and store it for later sessions.
Back to top
View user's profile Send private message
Deewiant



Joined: 26 Dec 2005
Posts: 21
Location: Finland

PostPosted: Thu Jan 19, 2006 1:41 am    Post subject: Problem solved Reply with quote

The buffer thing was just to dramatise the amount of errors, really. I can redirect and change the buffer size just fine.

Crispy wrote:
As for the linker error, perhaps it wants .lib files and isn't finding them? Try rebuilding all of Derelict. Also try telling it to look for library files in C:\dmd\trunk\lib.

The problem was precisely that the libraries weren't being built properly - you'll note that the procedure I was going through was attempting to rebuild Derelict, which is what failed. The example.d is DerelictSDL's own example file. I even tried copying the .lib into the same directory - no-go. The library is found, but the library itself generates most of the errors.

Quote:
And finally, I really recommend that you use the Build utility. It makes things much easier.

I do use the Build utility. The problem originated in the .lib files themselves.

However, your post gave me an idea - I removed the -Xderelict from my build.cfg, thus causing Build to compile the Derelict modules into object files and link them in as necessary, instead of using the library. This worked.

Then, I realised that of course the files in C:\dmd\trunk are also in the derelict package. See the pattern here? I ran buildme.bat without the -Xderelict in build.cfg and sure enough, the libraries came out right - with over three times the file size and the correct symbols loaded in and everything.

So the problem's solved, and it was my mistake, really.

But IMHO "--Xderelict" really needs to be added to build_dbg.brf and build_release.brf to counter any custom build.cfg, as this shouldn't have happened in the first place.
Back to top
View user's profile Send private message
aldacron



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

PostPosted: Thu Jan 19, 2006 3:39 am    Post subject: Re: Problem solved Reply with quote

Deewiant wrote:
But IMHO "--Xderelict" really needs to be added to build_dbg.brf and build_release.brf to counter any custom build.cfg, as this shouldn't have happened in the first place.


I'm not following you. Why would you want to exclude the Derelict modules when building Derelict? What exactly were you trying to build? It isn't entirely clear to me from your posts what you are doing.

The example.d modules in each package are not configured in build_dbg.brf or build_release.brf. Those BRFs are only meant to build the Derelict libraries. Those particular examples are not even intended to be built. They are for demonstrative purposes only, i.e. they show the what is required to use Derelict in a program and nothing more.

The BRFs are configured to build the Derelict libs and nothing more. You should build them and store them off somewhere where the linker can find them for your own projects. If you build your own projects with Build and use BRF files, you would then include -Xderelict there. It makes no sense to add that to the Derelict BRFs.

Rereading your last post I get the impression that you are building Derelict each time you build the app. Is that correct? If that's what you really want to do, then you shouldn't be including the Derelict BRFs in that build chain. That is not what they are configured for. You'll have to set it up yourself for that.
Back to top
View user's profile Send private message Send e-mail
Deewiant



Joined: 26 Dec 2005
Posts: 21
Location: Finland

PostPosted: Thu Jan 19, 2006 4:26 am    Post subject: Re: Problem solved Reply with quote

aldacron wrote:
Deewiant wrote:
But IMHO "--Xderelict" really needs to be added to build_dbg.brf and build_release.brf to counter any custom build.cfg, as this shouldn't have happened in the first place.


I'm not following you. Why would you want to exclude the Derelict modules when building Derelict? What exactly were you trying to build? It isn't entirely clear to me from your posts what you are doing.

The example.d modules in each package are not configured in build_dbg.brf or build_release.brf. Those BRFs are only meant to build the Derelict libraries. Those particular examples are not even intended to be built. They are for demonstrative purposes only, i.e. they show the what is required to use Derelict in a program and nothing more.

The BRFs are configured to build the Derelict libs and nothing more. You should build them and store them off somewhere where the linker can find them for your own projects. If you build your own projects with Build and use BRF files, you would then include -Xderelict there. It makes no sense to add that to the Derelict BRFs.

Rereading your last post I get the impression that you are building Derelict each time you build the app. Is that correct? If that's what you really want to do, then you shouldn't be including the Derelict BRFs in that build chain. That is not what they are configured for. You'll have to set it up yourself for that.

No, you've got me all wrong. I'll try to explain more clearly.

The original problem was that I was trying to reinstall Derelict from scratch, but for some reason the libraries were built incorrectly, which I found by trying to compile the example.d files.

I found that the problem was that I had "-Xderelict" in my build.cfg - which is there for usual situations, since I do not wish Build to link with the Derelict object files which it would normally auto-compile, finding them in dmd\src\derelict.

This setting, however, also prevented me from building Derelict properly since I was, as you say, excluding the Derelict modules when building it. This was my mistake - I had forgotten about the "-Xderelict" setting and/or I didn't realise that it prevented also the newly checked-out-from-SVN Derelict modules from being compiled into a library.

Now, what I am suggesting is that "--Xderelict" be added into the Build response files that come with Derelict. And this is what I think you missed: the two hyphens at the beginning - it means that any "-Xderelict" is to be nullified. The idea is to prevent my mistake from occurring to someone else, since I think such "-X"-settings in Build are quite common, and it's easy to forget they're there screwing things up for you when building the library.
Back to top
View user's profile Send private message
Crispy



Joined: 26 Nov 2005
Posts: 67

PostPosted: Thu Jan 19, 2006 2:22 pm    Post subject: Re: Problem solved Reply with quote

Deewiant wrote:
The problem was precisely that the libraries weren't being built properly - you'll note that the procedure I was going through was attempting to rebuild Derelict, which is what failed. The example.d is DerelictSDL's own example file. I even tried copying the .lib into the same directory - no-go. The library is found, but the library itself generates most of the errors.

Right, sorry, my mistake. Smile
Back to top
View user's profile Send private message
aldacron



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

PostPosted: Fri Jan 20, 2006 12:41 am    Post subject: Re: Problem solved Reply with quote

Deewiant wrote:
Now, what I am suggesting is that "--Xderelict" be added into the Build response files that come with Derelict. And this is what I think you missed: the two hyphens at the beginning - it means that any "-Xderelict" is to be nullified. The idea is to prevent my mistake from occurring to someone else, since I think such "-X"-settings in Build are quite common, and it's easy to forget they're there screwing things up for you when building the library.


I understand now. I never considered that. I'm not very fond of global configurations as they can cause more trouble than their worth. I configure everything on a per-project basis. That's why I had never run in to this problem.

Anyway, sounds reasonable to me.
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