Date: Mon, 12 Oct 1998 22:52:06 +0200 (MET DST) From: Wojciech Piechowski To: djgpp AT delorie DOT com Subject: Re: linking from nasm In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com On Mon, 12 Oct 1998, Mark A Reed wrote: > I have a global function in my file assembled by NASM. > I want to use that in my .cpp file compiled by DJGPP. But, it keeps saying > can't find myGlobalFunc. How exactly do you link in the file? heres my > assembly code and cpp code. > > global _myfunc > _myfunc: push ebp > mov ebp,esp > mov eax,[ebp+8] > leave > ret > > now in my .cpp file > > #include > extern int _myfunc(int); You should prevent the compiler from mangling the function name (or use the manged one in the assembly file - doesn't look nice and you don't need this now). The second thing is that the underscore should not be here - it is automatically inserted by the compiler. Better do this: extern "C" int myfunc(int); --------------------\ Wojciech Piechowski /---------------------------- Student informatyki \ voyt AT ds2 DOT pg DOT gda DOT pl / Student of computer science Politechnika Gdanska \________________/ Technical University of Gdansk