From: Jamie Grier Newsgroups: comp.os.msdos.djgpp Subject: Re: Need help linking NASM code with DJGPP program Date: Mon, 27 Oct 1997 17:12:31 -0700 Organization: Colorado State University Lines: 52 Message-ID: <34552DEF.AE2B4B73@cs.colostate.edu> References: <6325oq$60t AT pukrs7 DOT puk DOT ac DOT za> NNTP-Posting-Host: slip18.cs.colostate.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk > The object file is created with: nasm -f coff grfx_a.asm > Now, when I try to link the external routine into my DJGPP C++ > program, the linker responds with: > "undefined reference: void GRFXBackgrBlit(unsigned char *, unsigned > char *, int)" > All the other assembler functions (GRFXClearBuffer etc.) link orrectly > with the same type of header file. So the problem doesn't seem to be > with the C++ portions of the program. > > I discovered that removing one of the pointers from the GRFXBackgrBlit > parameter list in both the C++ and assembler source files causes the > function to be recognised by the DJGPP linker. It seems that one is > unable to use two pointers as parameters in an external function. But > this surely can't be. > > I would appreciate it if someone could explain to me what I'm doing > wrong. Please mail me at: > 9618872 AT pukrs3 DOT puk DOT ac DOT za > I will send a summary to the newsgroup at a later stage. > > Rudolf Visagie The easiest way to solve your problem would be to declare your external functions using the modifier "C". This tells the linker to use "C" style linking: extern "C" functionName(type, type, etc) Then just leave off the C++ name mangling in your .asm files. For example the above would just be: _functionName: mov ax, bx etc. If you don't want to do this than you can also compile your C++ source file into an assembly file and look to see exactly what function name it's expecting: gcc -S source.cc Just look for the corresponding call in the .s file that's generated.. call _functionName__FPUcii or whatever. Hope this helps.... -- Jamie Grier, CS student Colorado State University http://www.cs.colostate.edu/~grier