From owner-freebsd-hackers Sat Aug 5 13: 4: 0 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from hplms26.hpl.hp.com (hplms26.hpl.hp.com [15.255.168.31]) by hub.freebsd.org (Postfix) with ESMTP id E37D937B5DB for ; Sat, 5 Aug 2000 13:03:57 -0700 (PDT) (envelope-from iari@exch.hpl.hp.com) Received: from hplms2.hpl.hp.com (hplms2.hpl.hp.com [15.0.152.33]) by hplms26.hpl.hp.com (8.9.3 (PHNE_18979)/HPL-PA Relay) with ESMTP id NAA13859 for ; Sat, 5 Aug 2000 13:03:57 -0700 (PDT) Received: from hplex1.hpl.hp.com (hplex1.hpl.hp.com [15.0.152.182]) by hplms2.hpl.hp.com (8.10.2/8.10.2 HPL-PA Hub) with SMTP id e75K3uG15899 for ; Sat, 5 Aug 2000 13:03:56 -0700 (PDT) Received: from 15.0.152.182 by hplex1.hpl.hp.com (InterScan E-Mail VirusWall NT); Sat, 05 Aug 2000 13:03:56 -0700 (Pacific Daylight Time) Received: by hplex1.hpl.hp.com with Internet Mail Service (5.5.2650.21) id ; Sat, 5 Aug 2000 13:03:56 -0700 Message-ID: <140D21516EC2D3119EE700902787664401DA4DE8@hplex1.hpl.hp.com> From: "Ari, Ismail" To: "'freebsd-hackers@freebsd.org'" Subject: Problem linking/integrating Socket stuff into my driver code Date: Sat, 5 Aug 2000 13:03:55 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi everyone, I wrote pseudo-device driver for FreeBSD kernel. It safely comes up at boot time. There is also a corresponding device node "/dev/mydevice" for my code, so that whenever someone makes an: fd = open("/dev/mydevice", .. ); ioctl( fd, COMMAND ); the "mydevioctl()" function within my code will take care of the COMMAND requested. ***** NOW , My problem is !! ****** I tried to add some networking functionality to my driver. Although I #include'd every required socket and net related header in my code , , and etc. I get the errors "Undefined reference to socket()" , same for connect(), gethostbyname(), accept() etc. In my previous life B.K. ( Before Kernel ) I used to link to socket related libraries ( -lsocket, -lnls ), but this is not a standalone program and I am not supposed to make explicit linking to any library. This is KERNEL anyway, it has object code for almost every standard function you may want to use (e.g.socket() ..) For example: kern/uipc_syscalls.o has the socket() definition and uipc_syscalls.o is already in the list of object files to be used in kernel make; all being compiled together. After including the required header files and after ensuring with ( >> nm -s uipc_syscalls.o ) that socket() is defined there, how do I get my code to see these functions. Some Bullets that might help ------------------------------------------------------------------ * FUNNY:: I wrote a small client/server chat program (for testing) ;compiled both client and server code using "cc -o server server.c", "cc -o client client.c" and DID NOT LINK any special library... IT WORKED ??!! I put server code on another PC over network and they get to communicate with the client. "cc" somehow knows where to link I guess (Is there a list of the libraries that cc links somewhere? or does it just look under /usr/lib).. And the second funny thing is that, when I do a symbol lookup ">> nm -s client" on the client program the functions that I use , socket(), gethostbyname() still look U ( Unresolved, Undefined ?) * Kernel Makefile first compile everything with "cc -c " , i.e. "don't link at this time" option * After everything is compiled, kernel links them together using linker ld * cc without any option does all the compiling and linking job, but I am bound to use the KERNEL's rules "cc -c" first then link everything together. * Other drivers in the kernel ( e.g. aha SCSI driver) don't have any compile and linking problem and usually none of them need a special treatment for linking. Check /usr/src/sys/compile/GENERIC -> Makefile . NORMAL_C type of compilation is enough for them. Please Respond to: iari@hpl.hp.com AND/OR ismailari@yahoo.com Best Regards, Ismail Ari HP Labs To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message