Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

char *crypt(const char *key, const char *salt)); 1

Status
Not open for further replies.

Bangieff

Technical User
Feb 12, 2001
52
BG
Hi all
Can anyone tell me whats wrong with this fragment:

cout << crypt(&quot;qwerty&quot;,&quot;ab&quot;);

but when I try to compile it, I'm getting this:

undefined reference to 'crypt'

Thanks in advance
 
Well It almost worked :)
It now says: warning implicit declaration of function 'int crypt(...)'....

There is something wrong here, I just read the man pages (man crypt) and there is said that crypt is char *crypt....

I'm confused and any ideas will be apretiated

P.S: the same program is compiled without any problems on elder Linux Slackware distributions...
 
Make sure these 2 lines occur at the top of your source file in this order:

#define _XOPEN_SOURCE
#include <unistd.h>

It seems the prototype for crypt() is preprocessed out if _XOPEN_SOURCE is not defined.

You may want to check the synopsis on your man page for crypt in case the define isn't the same.

Russ
bobbitts@hotmail.com
 
It's perfect now
thanks

where can I found any documentation about the g++'s switches (like -lcrypt)
 
You can look in the man or info pages. The g++ switch there is -l, the &quot;crypt&quot; part is just the library name, so this could be anything depending on which library you want to link into your program. It's basically telling the compiler: &quot;I want to link a library into my program, and it's name is crypt.&quot; The linker will look into the usual places for the library called &quot;crypt&quot; and link it into your program if it can find it.

Russ
bobbitts@hotmail.com
 
If the code is vanilla ANSI/ISO C or C++ (not very likely), you should be able to port it with little or no changes. If your program uses system-specific stuff like graphics, networking, serial port routines etc., heavily uses the Win32 API and/or MFC you will have some work on your hands.

There's another forum on TT called &quot;Code Reuse and Migration&quot; which might be a better place for this kind of question.

Russ
bobbitts@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top