Bug 91711

Summary: mesa-9.1.3: undefined reference to `wglGetProcAddress@4'
Product: Mesa Reporter: YuGiOhJCJ <yugiohjcj>
Component: OtherAssignee: mesa-dev
Status: RESOLVED NOTABUG QA Contact: mesa-dev
Severity: major    
Priority: medium CC: yugiohjcj
Version: 9.1   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description YuGiOhJCJ 2015-08-21 08:27:23 UTC
Hello,

Since I have cross-compiled mesa-9.1.3 (linux -> windows), I am unable to cross-compile software that are using the opengl32 library:

1) glfw-3.1.1:
$ make
[ 23%] Built target glfw
Linking C executable boing.exe
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xa9): undefined reference to `wglGetProcAddress@4'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xd0): undefined reference to `wglGetProcAddress@4'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x140): undefined reference to `wglGetProcAddress@4'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x207): undefined reference to `wglGetProcAddress@4'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x248): undefined reference to `wglGetProcAddress@4'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xe07): undefined reference to `wglCreateContext@4'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xe5b): undefined reference to `wglShareLists@8'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xebe): undefined reference to `wglDeleteContext@4'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x10da): undefined reference to `wglMakeCurrent@8'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x10f3): undefined reference to `wglMakeCurrent@8'
../src/libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x1213): undefined reference to `wglGetProcAddress@4'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/boing.exe] Error 1
make[1]: *** [examples/CMakeFiles/boing.dir/all] Error 2
make: *** [all] Error 2

2) glew-1.13.0:
$ make SYSTEM=linux-mingw32 CC=i686-pc-mingw32-gcc LD=i686-pc-mingw32-ld
i686-pc-mingw32-gcc -DGLEW_NO_GLU -DGLEW_BUILD -O2 -Wall -W -Iinclude   -o tmp/linux-mingw32/default/shared/glew.o -c src/glew.c
i686-pc-mingw32-ld -shared -soname libglew32.dll --out-implib lib/libglew32.dll.a     -o lib/glew32.dll tmp/linux-mingw32/default/shared/glew.o  -lopengl32 -lgdi32 -luser32 -lkernel32 
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x3cc): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x3e8): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x404): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x418): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x42c): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x440): more undefined references to `wglGetProcAddress@4' follow
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x1783f): undefined reference to `wglGetCurrentDC@0'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x178af): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x178c3): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x178de): undefined reference to `wglGetCurrentDC@0'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x1795a): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x17ae0): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x17afc): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x17b1a): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x17efc): undefined reference to `wglGetProcAddress@4'
tmp/linux-mingw32/default/shared/glew.o:glew.c:(.text+0x17f18): more undefined references to `wglGetProcAddress@4' follow
make: *** [lib/glew32.dll] Error 1

Maybe this can help to understand the problem:
$ nm /usr/i686-pc-mingw32/lib/libopengl32.a | grep wglGetProc
00000000 I __imp__wglGetProcAddress
00000000 T _wglGetProcAddress

Any idea why it happens?

Thank you.
Best regards.
Comment 1 YuGiOhJCJ 2015-08-27 09:35:04 UTC
OK I found how to solve this problem.
Instead of using the libopengl32.a file provided by mesa I need to use the one provided by my cross-compiler.
The problem is that my current cross-compiler [1] does not provide the /usr/i686-pc-mingw32/lib/libopengl32.a file.
So, I have installed a new cross-compiler [2] that does correctly the job.

Now, my cross-compiler already provides a /usr/i686-pc-mingw32/lib/libopengl32.a file.
So, I should not cross-compiling mesa because it will overrides this file that will contain incorrect symbols.

The libopengl32.a provided by my new cross-compiler contains the correct symbols:
$ nm /usr/i686-w64-mingw32/lib/libopengl32.a | grep wglGetProc
00000000 I __imp__wglGetProcAddress@4
00000000 T _wglGetProcAddress@4

The question is why I need to use the library provided by my cross-compiler and not the one from mesa?

[1] http://www.mingw.org/
[2] http://mingw-w64.org

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.