Matthew Kille wrote:
> Hi All,
>
> I'm trying to build a GAPI application using cegcc. As there doesn't 
> seem to be a import library ready made for this, I have attempting to 
> make one, but without much success.
>
> My gx.def file looks like this:
>
>    LIBRARY GX
>    EXPORTS
>    GXOpenDisplay
>    GXCloseDisplay
>    GXBeginDraw
>    GXEndDraw
>    GXOpenInput
>    GXCloseInput
>    GXGetDisplayProperties
>    GXGetDefaultKeys
>    GXSuspend
>    GXResume
>    GXSetViewport
>    GXIsDisplayDRAMBuffer
>
> And I'm using dlltool like this:
>
>    $ arm-wince-cegcc-dlltool -d gx.def -l libgx.a
>    $ cp libgx.a /opt/cegcc/arm-wince-cegcc/lib
>
> My test program then simply looks like this:
>
>    #include <windows.h>
>    #include <gx.h>
>
>    int WINAPI WinMain (HINSTANCE hInstance,
>                        HINSTANCE hPrevInstance,
>                        LPWSTR szCmdLine,
>                        int iCmdShow)
>    {
>      MessageBox (NULL, TEXT("Hello"), TEXT("Hello Demo"), MB_OK);
>      GXBeginDraw();
>      return (0);
>    }
>
> I compile it like this:
>
>    arm-wince-cegcc-g++ -Wall -D_WIN32_WCE=0x0420 -D_WIN32_IE=0x0400  -o 
> test.exe test.c -lgx
>
> But the resulting compiler output is this:
>
>    Info: resolving _CRT_MT by linking to __imp__CRT_MT 
> (auto-import/blah/Temp/cc9E2Xnc.o:test.c:(.text+0x34): undefined 
> reference to `GXBeginDraw()'
> collect2: ld returned 1 exit status
> )
>
> I suspected some kind of name mangling might be the cause, but whatever 
> I have tried gives me the same result as above.
>
> Where am I going wrong? Or am I barking up completely the wrong tree? :)
>
> Hope someone can help.
>   
Yep, name mangling is the problem. You are using the c++ compiler (g++), 
and your gx.h header,
which you didn't show, isn't declaring GXBeginDraw with "C" linkage. C++ 
uses a different mangling
scheme to support overloading, namespaces and classes,
so the linker is really looking for a function named _Z11GXBeginDrawv.

Declaring GXBeginDraw like ...:
extern "C" void GXBeginDraw (void);
... fixes it, or using gcc instead of g++ also fixes it.

The correct fix is to wrap your header with ' extern "C" ' ... :

#ifndef _GX_H
#define _GX_H

#ifdef __cplusplus
extern "C"
{
#endif

<rest of header here>

#ifdef __cplusplus
}
#endif

#endif

(Take a look at the other headers in src/w32api/include in the sources,
or in /opt/cegcc/arm-wince-cegcc/include in the binary releases to get a 
grasp.)

 ... and then you can use gcc or g++.
Once you get this into a working state, don't be shy and send us the def 
file and the header for inclusion in
future CeGCC releases. Thanks!

Cheers,
Pedro Alves

P.S.: Be sure to send us MSDN pointers describing the interfaces too.



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to