crypt 함수 사용시 에러

NamSa의 이미지

다음 코드를 컴파일 하면 다음과 같은 에러가 나오네요.

#gcc -o crypt crypt.c

/tmp/ccjpdET7.o(.text+0x94): In function `main':
: undefined reference to `crypt'
collect2: ld returned 1 exit status

코드는 아래와 같습니다

#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>

void get_salt(char **seed);
int main(int argc, char **argv)
{
    char *seed;
    if (argc != 2)
    {
        printf("Usage : ./crypt [passwd]\n");
        exit(0);
    }

    seed = (char *)malloc(3);
    memset(seed, '\0', 3);
    get_salt(&seed);

    printf("원  문 : %s\n", argv[1]);
    printf("암호문 : %s\n", crypt(argv[1], seed));

    free(seed);
}

void get_salt(char **seed)
{
    time_t now_time;

    char first_seed[3];
    char *salt_set="./abcdefghijklmnopqrstuvwxyz"
                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                   "0123456789";
    memset(first_seed, '\0', 3);
    time(&now_time);

    srandom((unsigned int)now_time);
    first_seed[0] = salt_set[random() % 64];
    first_seed[1] = salt_set[random() % 64];

    memcpy(*seed, first_seed, 3);
}

페도라코어3를 전체설치해서 라이브럴리가 없는것은 아닐텐데
맨페이지에 있는 것쳐럼 #include <unistd.h>도 인클루드 시켯는데
말이죠

버려진의 이미지

#gcc -o crypt crypt.c -lcrypt

해보세요.

NamSa의 이미지

감사 합니다..
이제 아무 에러도 안나네요

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.