View previous topic :: View next topic |
Author |
Message |
mtwatkin
Joined: 22 Feb 2006 Posts: 7
|
Posted: Wed Feb 22, 2006 2:31 pm Post subject: Help using derelict for linux |
|
|
I am trying use derelict on Linux, and I am having some difficulty. I compiled derelict from svn as follows:
Download and install build. Didn't change any config files or anything, so its all the default settings.
Code: | svn co http://svn.dsource.org/projects/derelict/trunk/
cd trunk
chmod 755 build-linux.sh build-config.sh
./build-config.sh
./build-linux.sh |
Everything compiles with no problems. I look in trunk/lib and I see 13 .a files.
Code: | cp lib/* /usr/lib/.
cp -r Derelict*/derelict ..
mv ../derelict /dmd/src/phobos/. |
This is where I am having some problems. I make a project directory, and inside it put an empty directory called obj, the following file main.d, and the following file Makefile.
main.d:
Code: | import derelict.opengl.gl;
void main()
{
DerelictGL_Load();
} |
Makefile:
Code: | DFILES = main.d
EXENAME = test
OBJ.DIR = obj
DFLAGS = -v -release
LIBS = \
-L-lderelictUtil \
-L-lderelictAL \
-L-lderelictILU \
-L-lderelictSDLNet \
-L-lderelictGL \
-L-lderelictILUT \
-L-lderelictSDLttf \
-L-lderelictGLFW \
-L-lderelictSDL \
-L-lderelictGLU \
-L-lderelictSDLImage \
-L-lderelictIL \
-L-lderelictSDLMixer
all: $(DFILES)
dmd $(DFILES) $(LIBS) -od$(OBJ.DIR) $(DFLAGS) -of$(EXENAME) |
when I type make, I get the following output:
Code: | dmd main.d -L-lderelictUtil -L-lderelictAL -L-lderelictILU -L-lderelictSDLNet -L-lderelictGL -L-lderelictILUT -L-lderelictSDLttf -L-lderelictGLFW -L-lderelictSDL -L-lderelictGLU -L-lderelictSDLImage -L-lderelictIL -L-lderelictSDLMixer -odobj -v -release -oftest
parse main
semantic main
semantic2 main
semantic3 main
code main
generating code for function 'main'
gcc obj/main.o -o test -lphobos -lpthread -lm -Xlinker -lderelictUtil -Xlinker -lderelictAL -Xlinker -lderelictILU -Xlinker -lderelictSDLNet -Xlinker -lderelictGL -Xlinker -lderelictILUT -Xlinker -lderelictSDLttf -Xlinker -lderelictGLFW -Xlinker -lderelictSDL -Xlinker -lderelictGLU -Xlinker -lderelictSDLImage -Xlinker -lderelictIL -Xlinker -lderelictSDLMixer
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictGL.a(internal.o):(.data+0x30): undefined reference to `_ModuleInfo_8derelict4util6loader'
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictGL.a(internal.o): In function `_D8derelict6opengl8internal7getProcFAaZPv':
/home/mtwatkin/trunk/DerelictGL/derelict/opengl/internal.d:9: undefined reference to `***'
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictGL.a(internal.o): In function `_D8derelict6opengl8internal12internalLoadFAaZv':
/home/mtwatkin/trunk/DerelictGL/derelict/opengl/internal.d:17: undefined reference to `***'
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictGL.a(internal.o): In function `_D8derelict6opengl8internal14internalUnloadFZv':
/home/mtwatkin/trunk/DerelictGL/derelict/opengl/internal.d:22: undefined reference to `***'
collect2: ld returned 1 exit status
--- errorlevel 1
make: *** [all] Error 1 |
(if you are wondering about the ***s in the compiler output, those were really long symbols, and when I tried submitting the thread, it threw a SQL error saying that the really long word could not be added as a search word. If those symbols are important, please let me know)
If I change main.d to use only phobos modules, then it compiles and executes just fine, so I am pretty sure I set up dmd correctly. Please try to keep in mind that I switched to Linux less than a week ago, so when trying to get this working, I am just making educated guesses about how this is supposed to work on Linux. I am not sure how close my guesses are to what I am actually supposed to be doing, so if it seems like I did something dumb, I probably did. I am also kind of new to working with non-standard libraries, so I don't really know what I am doing there either. I have been using the downloadable derelict in Windows for a long time, and truth be told, I am not sure how I got it working. I just toyed with it till it worked, then copied my makefile from project to project to keep it working. Please help me get this working!
Also, incase this is important, since I installed Linux a week ago, I am using a dmd that is less than a week old, though I am not sure of the version number. Unless a new version has come out in the last week, I am using the latest. |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Wed Feb 22, 2006 8:07 pm Post subject: |
|
|
Yeah, those missing symbols are fairly important to determine what is going wrong. Without them, one can only guess. But there are a couple of things worth pointing out.
* there's no need to link with every single derelict library. Only link with the ones you need to use. Linking with both DerelictGLFW and DerelictSDL, for example, makes no sense. Minimizing the libraries you link with will help reduce the chance of build errors.
* gcc, which DMD uses as a backend on Linux, is very picky about the order in which libraries are specified on the command line. This page should help explain that a bit.
Given the one symbol you didn't replace with ***, my guess is that the problem comes from derelictUtil being passed first in the library list. Here's what I suggest:
1) Remove all extraneous libraries from the command line - if you are using OpenGL then at a minimum you need DerelictUtil, DerelictGL and either DerelictSDL or DerelictGLFW (but not both).
2) Make sure you pass derelictUtil last, since all other Derelict libraries depend upon it. |
|
Back to top |
|
|
mtwatkin
Joined: 22 Feb 2006 Posts: 7
|
Posted: Wed Feb 22, 2006 10:57 pm Post subject: |
|
|
Thanks, but I am still having the problem. I changed Makefile as per your suggestion to read
Code: | DFILES = main.d
EXENAME = test
OBJ.DIR = obj
DFLAGS = -v -release
LIBS = \
-L-lderelictGL \
-L-lderelictSDL \
-L-lderelictUtil
all: $(DFILES)
dmd $(DFILES) $(LIBS) -od$(OBJ.DIR) $(DFLAGS) -of$(EXENAME) |
(I tried switching derelictGL and derelictSDL, but it still didn't compile. Here is the compiler output of this
Code: | dmd main.d -L-lderelictGL -L-lderelictSDL -L-lderelictUtil -odobj -v -release -oftest
parse main
semantic main
semantic2 main
semantic3 main
code main
generating code for function 'main'
gcc obj/main.o -o test -lphobos -lpthread -lm -Xlinker -lderelictGL -Xlinker -lderelictSDL -Xlinker -lderelictUtil
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictUtil.a(loader.o): In function `_D8derelict4util6loader22Platform_LoadSharedLibFAaZC8derelict4util6loader9SharedLib':
/home/mtwatkin/trunk/DerelictUtil/derelict/util/loader.d:90: undefined reference to `dlopen'
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictUtil.a(loader.o): In function `_D8derelict4util6loader24Platform_UnloadSharedLibFC8derelict4util6loader9SharedLibZv':
/home/mtwatkin/trunk/DerelictUtil/derelict/util/loader.d:99: undefined reference to `dlclose'
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictUtil.a(loader.o): In function `_D8derelict4util6loader16Platform_GetProcFC8derelict4util6loader9SharedLibAaZPv':
/home/mtwatkin/trunk/DerelictUtil/derelict/util/loader.d:105: undefined reference to `dlsym'
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictUtil.a(loader.o): In function `_assert_8derelict4util6loader':
DerelictUtil/derelict/util/loader.d:(.gnu.linkonce.t_assert_8derelict4util6loader+0x19): undefined reference to `_d_assert'
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictUtil.a(exception.o): In function `_D8derelict4util9exception22SharedLibLoadException13sharedLibNameFZAa':
/home/mtwatkin/trunk/DerelictUtil/derelict/util/exception.d:29: undefined reference to `_D9invariant12_d_invariantFC6ObjectZv'
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictUtil.a(exception.o): In function `_D8derelict4util9exception26SharedLibProcLoadException8procNameFZAa':
/home/mtwatkin/trunk/DerelictUtil/derelict/util/exception.d:58: undefined reference to `_D9invariant12_d_invariantFC6ObjectZv'
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../libderelictUtil.a(exception.o): In function `_D8derelict4util9exception31InvalidSharedLibHandleException13sharedLibNameFZAa':
/home/mtwatkin/trunk/DerelictUtil/derelict/util/exception.d:81: undefined reference to `_D9invariant12_d_invariantFC6ObjectZv'
collect2: ld returned 1 exit status
--- errorlevel 1
make: *** [all] Error 1 |
Symbols are in this time. Thanks for your help, I appreciate it.
Edit: No SQL error this time. |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Thu Feb 23, 2006 1:01 am Post subject: |
|
|
You need to link with the dynamic library linker also with Derelict on Linux. So add -L-ldl to the command line.
That will solve the issue with the dl* error messages...
As for the other errors with "invariant", I think that has something to do with phobos. You may need to add a second reference to libphobos.a on the end of the command line (give the full path if necessary). You really shouldn't have to do this, but give it a try anyway to see if that fixes it.
But first... just try the first fix above to see if that gets rid of all the link errors. That may be all that's wrong.
-JJR |
|
Back to top |
|
|
mtwatkin
Joined: 22 Feb 2006 Posts: 7
|
Posted: Thu Feb 23, 2006 6:10 pm Post subject: |
|
|
Thanks JJR, I changed Makefile to read
Code: | LIBS = -L-ldl \
-L-lderelictGL \
-L-lderelictSDL \
-L-lderelictUtil \
-L-lphobos |
and now it successfully compiles. When I run the above main.d, it says "Failed to load proc glXGetProcAddress from shared library libGL.so", which seems to be the same problem that clayasaurus was having near the bottom of this thread http://www.dsource.org/forums/viewtopic.php?p=5296&sid=b4b5391f469112fc69404743eda33d9c
I followed the advice he gave in the thread to use the selective loading mechanism, which is documented here (for the benefit of people who have this problem in the future) and everything is working now! Thanks for your help. |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Thu Feb 23, 2006 11:57 pm Post subject: |
|
|
Glad I could help. Those of us who have used Derelict have run into some of these problems before. As you showed in the link, the glXGetProcAddress problem seems to crop up only in some systems. I don't know why but apparently that function is not available on all Linux X Windows systems. Strange. I'm not sure what can be done about it. For now, at least, you found the fix. But maybe it should be documented in Derelict.
-JJR |
|
Back to top |
|
|
|
|
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
|