From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: Nasm & Gcc. HELP! Organization: Pin Eight Software http://pineight.8m.com/ Message-ID: References: <934tdg$oj0$1 AT nnrp1 DOT deja DOT com> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 63 X-Trace: +LkLmgGeDkTBzHawEMhNGPNi0isN0BrzM03Rk3xb3feB/hUSt+p5MOugULHDQSgrjoAHJ/GbnPFJ!LtPpYZgD3iJlNi3ZDI9Yc51zmtZIb/wx1o0ywMqsKqb9frbWJXVkhXWYtf8qPXW4N4Szsbf0PfT/!iA== X-Complaints-To: abuse AT gte DOT net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Fri, 05 Jan 2001 18:05:02 GMT Distribution: world Date: Fri, 05 Jan 2001 18:05:02 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Fri, 05 Jan 2001 16:40:17 GMT, pixelpajas AT my-deja DOT com wrote: >Hi .. I'm trying to learn how to use nasm >assembler code with gcc but i get an error when i >link the objects. Below are the source files and >command compile/link entries. > > > >- 4k.c ---------------------------------------- > >extern unsigned int keyget(unsigned int); > >void main(void) >{ > keyget(1); >} > >----------------------------------------------- > > >- lib.asm ------------------------------------- > >[BITS 32] >[GLOBAL _key] >[SECTION .text] > > >_key: MOV CX,1 [snip] >first i build lib.asm -> nasm -f coff lib.asm > >then i compile 4k.c -> gxx -nostdlib -nostdinc - >fno-builtin -fno-exceptions -c -O3 4k.c -r > >and at last i try to link -> ld -nostdlib - >nostdinc -fno-builtin -fno-exceptions -e _main - >oformat binary -o 4k.com 4k.o lib.o > >but in the last step i get -> " 4k.o >(.text+0x6):4k.c: undefined reference to `_keyget >(unsigned int)' " 1. The function should be called _keyget not _key in the asm source. 2. You are trying to compile C programs with gxx, which assumes all source is C++. (Use .cc or .cpp extension for C++ source.) 3. Because of this, you are trying to use C++ calling conventions for a C calling conventions function. Try wrapping your prototypes with extern "C" { /* prototypes */ } --