Unhandled exception when calling opengl functions.
Original Reporter info from Mantis: FPCCore
-
Reporter name: FPC core team
Original Reporter info from Mantis: FPCCore
- Reporter name: FPC core team
Description:
Upon calling any opengl function the program crashes with this error:
An unhandled exception occurred at 0x00000000 :
EA
$00000000
$0001057C
$000578E4
$00057464
$00058250
$909F7184
$901AA650
$901AF060
$909F4FD0
$92EE37B8
$92EE36A4
$92EE38D4
$90A4A544
$90A50C6C
$91674A68
$916778B0
$91674CA8
$928C47F4
$92DD2C0C
$92DE93B0
$92DFD718
$000581D8
$0005849C
$0000243C
$000022B0
$00000001
I tried manually telling the compiler to link libGL.dylib with {$LINKLIB gl}, but that just generated this linker error:
/usr/bin/ld: warning dynamic shared library: /usr/x11r6/lib//libgl.dylib not made a weak library in output with MACOSX_DEPLOYMENT_TARGET environment variable set to: 10.1
I saw in gl.pp that the functions are declared as variables and assigned the addresses those functions. I altered the declaration of glViewport (the first opengl function I call) to a more standard external declaration:
procedure glViewport(x, y: GLint; width, height: GLsizei); extdecl; external 'libGL.dylib;
Then I had to insert a {$LINKLIB gl}
And I was able to call it without crashing. Though the program then crashed when calling the next, unmodified, opengl function.
I've noticed that freepascal on mac os x has quite a few issues with linking, in fact my program starts with several {$LINKLIB} directives. So perhaps this is a linking issue? Maybe it's assigning an incorrect or nonexistant address to the functions? This would certainly cause an exception if that function was called.
Additional information:
Reporter: Jason Bell
EMail: bell_jason at yahoo dot ca
Mantis conversion info:
- Mantis ID: 5255
- OS: Mac OS X
- Version: 1.9.5
- Fixed in version: 1.9.5