Date: Wed, 4 Nov 2009 09:31:33 +0100 From: Oliver Mahmoudi <olivermahmoudi@gmail.com> To: Gabor Kovesdan <gabor@freebsd.org>, f.loeber@googlemail.com Cc: freebsd-hackers@freebsd.org Subject: Re: writing a FreeBSD C library Message-ID: <6b4b2d2c0911040031h2175011dy949e4d368ffbb997@mail.gmail.com> In-Reply-To: <4AE60F70.9070808@FreeBSD.org> References: <6b4b2d2c0910261308i367569dbg887d7c713bf20ad1@mail.gmail.com> <4AE60F70.9070808@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Thank you for your emails. Neither one of the methods that you two suggested brought about the desired solution, but I have solved it. using gcc for the plain source with the -I switch gives: % gcc -o aprog aprog.c -I ~/mylib/ /var/tmp//ccHrDiyd.o(.text+0x19): In function `main': : undefined reference to `myprnf' creating an object file first and then linking with ld gives me: % ld -o aprog aprog.o mylib.a ld: warning: cannot find entry symbol _start; defaulting to 0000000008048080 mylib.a(lb.o)(.text+0x33): In function `_myprf': : undefined reference to `puts' whereas placing mylib.a before the -o switch and then linking with ld gives: % ld mylib.a -o aprog aprog.o ld: warning: cannot find entry symbol _start; defaulting to 0000000008048080 aprog.o(.text+0x19): In function `main': : undefined reference to `myprnf' which is essentially the same message it gives when compiling and linking with gcc in one step. The fact that the order of the arguments matters is also mentioned somewhere in gcc(1) and ld(1). The solution was to simply compile and link it like so: % gcc -o testfile aprog.c mylib.a % ./testfile hello world % This is in essence a synthesis of what you two suggested. Anyways, thanks again. Oliver >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6b4b2d2c0911040031h2175011dy949e4d368ffbb997>