I have a makefile with: -lsocket -lnsl at the end of a line(i will post the full makefile later).
I have no clue what those do. The program compiled and ran succesfully under Solaris but when I tried in Mac OSx I get an error saying that I dont have the files for lscoket or lnsl. I removed those statements and it compiled but did not run properly.
Any help would be appreciated.
August 5th, 2004, 01:54 PM
As far as I am aware, "-l" includes a library, so what you posted would include the socket and nsl libraries. Are you using the same compiler on osx? Because it could be that it doesn't have those libraries, or that you need different source because the code you have is not totally portable.
August 6th, 2004, 07:50 AM
what i think is the libraries used by the program for execution aren't there in Mac because there are some files which are present in Solaris but aren't compatible with Mac but if u use Mac os10 the program may work. the program on't work by deleting -I... statements because the program might not be able execute without those, what u can do to clarify the requirement of these statements is try to run the program without the statements in solaris!
if the program don't work, then u can't delete these statements else the the these aren't important. happy programming..:->
August 6th, 2004, 10:43 AM
The exact -l settings required vary slightly between different Unix-like systems.
Linux requires neither -lsocket or -lnsl to compile most sockets programs. I suspect MacOS does not either. In this case the socket and nsl libraries are built in to the C library which is linked by default.
Try it without them.
August 10th, 2004, 01:14 PM
hey all, under MacOSX, if I remove the -lsocket and -lnsl the program compiles but when I run it it doesn't work properly. Those lines are required for compilation under Solaris, and the program works perfectly there.
Any further help will be appreciated.
August 10th, 2004, 04:36 PM
It would help knowing what "it doesn't run properly" means. Does it crash? Does it give you the wrong results? It doesn't do what's expected? What is expected?
August 10th, 2004, 08:13 PM
Ok, here goes the full explanation. I wrote a networking program in C that transfers a file using UDP. The file is split into packets and sent. I did it as an assignment at university. It compiled and ran perfectly on the Solaris machines at my school. I am just trying to port it and make it work on my Powerbook running MacOSX. I have not altered the code functionality in any way. I modified the makefile deleting the -lsocket -lnsl line then it compiled on the Mac.
I ran the program on the Mac the same way I did at school just testing to transfer the file in localhost. Problem is it doesn't send anything it doesn't crash or give any seg faults. It just sends packet 0 over and over without receiving at the other end. It is very weird because the code was fine and it worked and sent any file under Solaris. I did not change any lines of code and it doesn't seem to work on the Mac. I assumed that removing the -lsocket -lnsl line on the makefile has some influence over program functionality.
(BTW I got a 9.2/10 for that assignment)
Is it an issue with my version of gcc? or maybe MacOSX is not as much unix as it claims to be?