From: Brian B. <br...@da...> - 2007-01-23 09:49:53
|
I know, I know. I've seen lots of these in the archives and in google but I still didn't get things to work. Here's the source code: #include <windows.h> #include <gl/gl.h> // this wont do anything interesting but it SHOULD link! int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { glLoadIdentity(); return 0; } Here's the error message (and no others): C:\Temp/ccs7baaa.o:test.cpp:(.text+0x7): undefined reference to `glLoadIdentity@0' Here's what I'm doing: pexports -o c:\windows\system32\opengl32.dll > opengl32.def dlltool -d opengl32.def -U -l libopengl32.a g++ -Wall -o eg.exe -mwindows test.cpp libopengl32.a Here's the first few lines of the def file: LIBRARY OPENGL32.dll EXPORTS GlmfBeginGlsBlock @1 GlmfCloseMetaFile @2 GlmfEndGlsBlock @3 ... glLoadIdentity @165 Notes: 1. nm -u libopengl.a shows only __head_libopengl32_a as undefined (in multiple files) 2. nm -u test.o shows only _glLoadIdentity@0 as undefined. 3. This happens even if I don't create my own libopengl32.a (ie, use the one from w32api-3.6.tar.gz). 4. This happens with the original (Mesa) header files, the MS header files (from Borland C++ Builder) and the nVidia header files as well (so its probably not a __cdecl/__stdcall issue) From the nVidia file: WINGDIAPI void APIENTRY glLoadIdentity (void); 5. I'm using: binutils-2.16.91-20060119-1.tar.gz (though same issue with binutils-2.15.91-20040904-1.tar.gz) gcc-core-3.4.2-20040916-1.tar.gz gcc-g++-3.4.2-20040916-1.tar.gz mingw-runtime-3.9.tar.gz mingw-utils-0.3.tar.gz w32api-3.6.tar.gz on Windows XP. 6. These are the latest links I tried: http://www.mingw.org/mingwfaq.shtml#faq-msvcdll <http://www.mingw.org/MinGWiki/index.php/Glut?PHPSESSID=54cdd9e3099a2a6b87d403eed7dedba5>http://sourceforge.net/forum/forum.php?thread_id=1291743&forum_id=286529 <http://sourceforge.net/forum/forum.php?thread_id=1291743&forum_id=286529> http://www.mingw.org/MinGWiki/index.php/Glut?PHPSESSID=54cdd9e3099a2a6b87d403eed7dedba5 specifically, the second batch of 'errors you might see' seemed promising. <http://sourceforge.net/forum/forum.php?thread_id=1291743&forum_id=286529> PLEASE HELP! Where's the "@0" coming from in test.o? How can I get this to link? Thanks, Brian. |
From: Brian D. <br...@de...> - 2007-01-23 19:24:54
|
Brian Bruinewoud wrote: > I know, I know. I've seen lots of these in the archives and in google > but I still didn't get things to work. > > Here's the source code: > #include <windows.h> > #include <gl/gl.h> > > // this wont do anything interesting but it SHOULD link! > int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR > lpCmdLine, int nCmdShow) > { > glLoadIdentity(); > return 0; > } Your test case compiles just fine for me with "gcc gltest.c -o gltest -lopengl32" using the stock opengl32 import library contained in w32api. You are making things much harder by trying to create your own import library. > Here's what I'm doing: > pexports -o c:\windows\system32\opengl32.dll > opengl32.def > dlltool -d opengl32.def -U -l libopengl32.a > g++ -Wall -o eg.exe -mwindows test.cpp libopengl32.a > > Here's the first few lines of the def file: > LIBRARY OPENGL32.dll > EXPORTS > GlmfBeginGlsBlock @1 > GlmfCloseMetaFile @2 > GlmfEndGlsBlock @3 > ... > glLoadIdentity @165 This won't work. Look at the source package to w32api and opengl32.def for how to create a working import library. The symbols exported by the DLL don't have the standard @n stdcall function decoration, but that is the convention that gcc expects to call. Thus you have to create an import library with aliases. But again there is no reason for you to have to do this as w32api has already done it for you. > Where's the "@0" coming from in test.o? Because that is how the gcc stdcall calling convention decorates its function names. Brian |
From: Brian B. <br...@da...> - 2007-01-24 09:08:59
|
Brian, I did initially try the simple and obvious solution and it didn't work, which is what began my painful exploration below. However, it does now work, though I'm not sure what changed (which is annoying). I'm going to re-extract the mingw installation and try and find out what was wrong and how it was fixed. Thanks for your help. In future, how do I create a proper def file for gcc? That is, with the @n annotations? Thanks, Brian. Brian Dessent wrote: >Brian Bruinewoud wrote: > > > >>I know, I know. I've seen lots of these in the archives and in google >>but I still didn't get things to work. >> >>Here's the source code: >> #include <windows.h> >> #include <gl/gl.h> >> >> // this wont do anything interesting but it SHOULD link! >> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR >>lpCmdLine, int nCmdShow) >> { >> glLoadIdentity(); >> return 0; >> } >> >> > >Your test case compiles just fine for me with "gcc gltest.c -o gltest >-lopengl32" using the stock opengl32 import library contained in >w32api. You are making things much harder by trying to create your own >import library. > > > >>Here's what I'm doing: >> pexports -o c:\windows\system32\opengl32.dll > opengl32.def >> dlltool -d opengl32.def -U -l libopengl32.a >> g++ -Wall -o eg.exe -mwindows test.cpp libopengl32.a >> >>Here's the first few lines of the def file: >> LIBRARY OPENGL32.dll >> EXPORTS >> GlmfBeginGlsBlock @1 >> GlmfCloseMetaFile @2 >> GlmfEndGlsBlock @3 >> ... >> glLoadIdentity @165 >> >> > >This won't work. Look at the source package to w32api and opengl32.def >for how to create a working import library. The symbols exported by the >DLL don't have the standard @n stdcall function decoration, but that is >the convention that gcc expects to call. Thus you have to create an >import library with aliases. But again there is no reason for you to >have to do this as w32api has already done it for you. > > > >>Where's the "@0" coming from in test.o? >> >> > >Because that is how the gcc stdcall calling convention decorates its >function names. > >Brian > >------------------------------------------------------------------------- >Take Surveys. Earn Cash. Influence the Future of IT >Join SourceForge.net's Techsay panel and you'll get the chance to share your >opinions on IT & business topics through brief surveys - and earn cash >http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >_______________________________________________ >MinGW-users mailing list >Min...@li... > >You may change your MinGW Account Options or unsubscribe at: >https://lists.sourceforge.net/lists/listinfo/mingw-users > > > |
From: Brian B. <br...@da...> - 2007-01-24 09:21:08
|
Brian Bruinewoud wrote: Ok, this is annoying. Now I can't get it to fail. I hate not knowing what was wrong (whether it was me or the environment or something). Anyway... >Brian, > >I did initially try the simple and obvious solution and it didn't work, >which is what began my painful exploration below. >However, it does now work, though I'm not sure what changed (which is >annoying). I'm going to re-extract the mingw installation and try and >find out what was wrong and how it was fixed. Thanks for your help. > >In future, how do I create a proper def file for gcc? That is, with the >@n annotations? > >Thanks, >Brian. > >Brian Dessent wrote: > > > >>Brian Bruinewoud wrote: >> >> >> >> >> >>>I know, I know. I've seen lots of these in the archives and in google >>>but I still didn't get things to work. >>> >>>Here's the source code: >>> #include <windows.h> >>> #include <gl/gl.h> >>> >>> // this wont do anything interesting but it SHOULD link! >>> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR >>>lpCmdLine, int nCmdShow) >>> { >>> glLoadIdentity(); >>> return 0; >>> } >>> >>> >>> >>> >>Your test case compiles just fine for me with "gcc gltest.c -o gltest >>-lopengl32" using the stock opengl32 import library contained in >>w32api. You are making things much harder by trying to create your own >>import library. >> >> >> >> >> >>>Here's what I'm doing: >>> pexports -o c:\windows\system32\opengl32.dll > opengl32.def >>> dlltool -d opengl32.def -U -l libopengl32.a >>> g++ -Wall -o eg.exe -mwindows test.cpp libopengl32.a >>> >>>Here's the first few lines of the def file: >>> LIBRARY OPENGL32.dll >>> EXPORTS >>> GlmfBeginGlsBlock @1 >>> GlmfCloseMetaFile @2 >>> GlmfEndGlsBlock @3 >>> ... >>> glLoadIdentity @165 >>> >>> >>> >>> >>This won't work. Look at the source package to w32api and opengl32.def >>for how to create a working import library. The symbols exported by the >>DLL don't have the standard @n stdcall function decoration, but that is >>the convention that gcc expects to call. Thus you have to create an >>import library with aliases. But again there is no reason for you to >>have to do this as w32api has already done it for you. >> >> >> >> >> >>>Where's the "@0" coming from in test.o? >>> >>> >>> >>> >>Because that is how the gcc stdcall calling convention decorates its >>function names. >> >>Brian >> >>------------------------------------------------------------------------- >>Take Surveys. Earn Cash. Influence the Future of IT >>Join SourceForge.net's Techsay panel and you'll get the chance to share your >>opinions on IT & business topics through brief surveys - and earn cash >>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >>_______________________________________________ >>MinGW-users mailing list >>Min...@li... >> >>You may change your MinGW Account Options or unsubscribe at: >>https://lists.sourceforge.net/lists/listinfo/mingw-users >> >> >> >> >> > >------------------------------------------------------------------------- >Take Surveys. Earn Cash. Influence the Future of IT >Join SourceForge.net's Techsay panel and you'll get the chance to share your >opinions on IT & business topics through brief surveys - and earn cash >http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >_______________________________________________ >MinGW-users mailing list >Min...@li... > >You may change your MinGW Account Options or unsubscribe at: >https://lists.sourceforge.net/lists/listinfo/mingw-users > > > |