|
undefined reference to `crypt'
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Benodach
(2 posts) bio
|
| Date |
Wed 07 Dec 2011 02:34 PM (UTC) [ quote
] |
| 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! | top |
|
| Posted by |
Benodach
(2 posts) bio
|
| Date |
Reply #1 on Thu 08 Dec 2011 06:32 PM (UTC) [ quote
] |
| 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. | top |
|
| Posted by |
Nick Gammon
Australia (18,772 posts) bio
Forum Administrator |
| Date |
Reply #2 on Fri 09 Dec 2011 03:34 AM (UTC) [ quote
] |
| 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 | 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.
2,215 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )