This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: NEED HELP: linking an exe with windows lib files


> 
> Come on gang...someone must know what to do about this...  Help me out
> here!
> 
> John A. Lewis wrote:
> > 
> > I am trying to build an executable which links in some libraries which
> > are intended for windows.  The symbols in these libraries have the _ in
> > front of them, which gcc seems to handle, and @4, @8, @12, etc. behind
> > them, which gcc does not seem to handle.  I am kind of a novice here, so
> > I have no idea what to do about this.
> > 
> > Any recommendations on how to fix this?
> > 

Look john: when that '@' symbol appears in a function, it means that its calling
convention is _stdcall, i.e. the arguments to it are pushed in the normal 
fashion for C functions, but it is the called function that cleans up the
stack.

This means that if you prototype correctly your calls, using the same headers
the library was built with, YOUR calls will have the '@' appended to them too,
and the link will work.

Your problem is a problem of using the right headers, and prototyping all
functions that have the _stdcall feature.

Imagine what would happen if the link would work:
You call the function 'foo' in your code, and after the call, the compiler
adds the size of the pushed arguments to the stack to adjust it:
	push	arg2
	push	arg1
	call	foo
	add	$8,%esp

Since foo is a _stdcall function, it would ALREADY have substracted the 8
from the stack, and when that code is run, the stack would be in a MESS!

When you declare that function 'foo' as stdcall, the compiler will
generate:
	push	arg2
	push	arg1
	call	foo@8

and nothing more, so everything will work OK.

What you have to do now is to use the same prototypes as the guys used for
building that library. That's all.


-- 
Jacob Navia	Logiciels/Informatique
41 rue Maurice Ravel			Tel 01 48.23.51.44
93430 Villetaneuse 			Fax 01 48.23.95.39
France
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]