64 bit compilation succeeds... OpenGL does not work anymore!

Started by pjot, January 05, 2009, 07:53:36 AM

Previous topic - Next topic

pjot

The 64bit compilation works fine:


Quote
peter@AsteroidRider:~/installation/newlisp-10.0.0$ make -f makefile_linux64LP64

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE newlisp.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-symbol.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-math.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-list.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-liststr.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-string.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-filesys.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-sock.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-import.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-xml.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-web.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-matrix.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-debug.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE pcre.c

gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o pcre.o  -g -lm -ldl -lreadline -lncurses -o newlisp

strip newlisp

peter@AsteroidRider:~/installation/newlisp-10.0.0$ file newlisp

newlisp: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped


Now, if I start the default 'opengl-demo.lsp' with newLisp as 64bit executable, we see a blue screen and no teapot.



Obviously, something goes wrong when passing values to the 64bit OpenGL libraries....?



I have changed the program like this:

 (begin
    (set 'GL_LIB "/usr/lib64/libGL.so")
    (set 'GLUT_LIB "/usr/lib64/libglut.so"))


And also verified if the libraries really were 64bit:


Quote
peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libGL.so

/usr/lib64/libGL.so: symbolic link to `libGL.so.1'

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libGL.so.1

/usr/lib64/libGL.so.1: symbolic link to `libGL.so.169.09'

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libGL.so.169.09

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libGL.so.169.09

/usr/lib64/libGL.so.169.09: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), stripped

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libglut.so      

/usr/lib64/libglut.so: symbolic link to `libglut.so.3'

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ newlisp opengl-demo.lsp

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libglut.so.3

/usr/lib64/libglut.so.3: symbolic link to `libglut.so.3.7.1'

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libglut.so.3.7.1

/usr/lib64/libglut.so.3.7.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), stripped


Any idea what may go wrong?



Regards

Peter

pjot

#1
I have a MUI program running OK with my FreeGLUT port. Other programs do not show anything either.



The MUI program however only passes INTEGER values as arguments to imported GL functions, and no doubles or floats.



Maybe there is an issue with passing doubles and floats in 64bit compilation?



Regards

pjot

#2
It turns out to be a problem with the (flt) function in 64bit mode.



I made a library (32 and 64 bit) and ran it with 32bit and 64bit versions of newLisp. This was the code:

#include <stdio>

void show(float f, double d)
{
    fprintf(stdout, "Float: %fnDouble: %fn", f, d);
}


32bit compilation
Quote
$ gcc -shared -fPIC -m32 -o lib.so lib.c

$ file lib.so

lib.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), not stripped

$ ./newlisp

newLISP v.10.0.0 on Linux IPv4, execute 'newlisp -h' for more info.



> (import "./lib.so" "show")

show <F7F693FC>

> (show (flt 1.1) 0.5)

Float: 1.100000

Double: 0.500000

33


So this seems to be OK. The '33' is the number of characters printed by 'fprintf'.



64bit compilation
Quote
$ gcc -shared -fPIC -o lib.so lib.c

$ file lib.so

lib.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), not stripped

$ newlisp

newLISP v.10.0.0 64-bit on Linux IPv4, execute 'newlisp -h' for more info.



> (import "./lib.so" "show")

show <2B22DBF3E53C>

> (show (flt 1.1) 0.5)

Float: 0.000000   --------------- ???

Double: 0.500000

33

> (exit)


The (flt) command in 64bit mode passes 0.000 instead of the 1.1 which should be passed. As the OpenGL libraries use a lot of 4byte floats, and also the opengl-demo.lsp program uses them, things go wrong.



Peter



EDIT: better readable now...