[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  ROM
. -> [Folder]  Compiling the server
. . -> [Subject]  undefined reference to `crypt'
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

undefined reference to `crypt'

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Benodach   (2 posts)  [Biography] bio
Date Wed 07 Dec 2011 02:34 PM (UTC)
Message
Should be an easy one...but it's tripping me up. I am running ROM 2.4 on Ubuntu. The crypt() calls have never given me a problem since I always link with -lcrypt in the Makefile.

However, the most recent OS update, which I believe included a gcc/glibc update, is now giving me the "undefined reference to 'crypt'" errors when it comes time to link.

My calls to crypt() in comm.c and act_info.c remain unchanged from stock code and I have not messed with the prototypes anywhere.

I'm running the latest version of Ubuntu which uses Linux 3.0, gcc 4.6.1 and glibc 2.13.

As I said above, crypt() has never given me problems as long as I link with -lcrypt but now it is. In the past, I have not needed to include crypt.h or unistd.h but when I tried including these it didn't fix the errors (in fact, the read() and write() prototypes in unistd.h cause further problems with conflicts in comm.c).

Any insight would be greatly appreciated. Thanks!
[Go to top] top

Posted by Benodach   (2 posts)  [Biography] bio
Date Reply #1 on Thu 08 Dec 2011 06:32 PM (UTC)
Message
I went back to the basics and (re)read the gcc man page...something I haven't done in well over 10 years. This paid off, as I noticed that within the command line syntax of gcc, it matters where you place the -l argument.

Thus, I adjusted my Makefile to reflect placing -lcrypt at the end of the command line and voila - problem solved. While my previous syntax was fine for earlier versions of gcc, it appears that is no longer the case.

So I presume gcc was now linking the crypt library after the object files in question and thus the call to crypt() was undefined.

I eventually figured it out but I'm re-posting here in the event someone else stumbles on this in the future.
[Go to top] top

Posted by Nick Gammon   Australia  (21,388 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Fri 09 Dec 2011 03:34 AM (UTC)
Message
Oh yeah, sorry I didn't reply sooner. The positional linking of libraries can trip you up a bit. It's because if you put it too early on the (linker) command line the linker sees no need to include it, so you need to put the "main" project early, and then things it needs later.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


5,793 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]