The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Problem with EVP_DigestInit

TwistedJesterTwistedJester Registered User regular
edited February 2009 in Help / Advice Forum
So I need to do this assignment for a class where we hash passwords with a salt and the professor suggests we look into the openssl library by doing a man EVP_DigestInit. Now, I am terrible with C, so I figured I'd just compile the example provided (which can be seen here) and toy around with it to understand it better. However, upon trying to compile it, gcc shits the bed and I can't make heads or tails of what it tells me. Here's what I get:

openssl.jpg

I haven't done any C in like, a year. Help?

TwistedJester on

Posts

  • ecco the dolphinecco the dolphin Registered User regular
    edited February 2009
    gcc is telling you that although you've used the EVG_xxx functions in your code, it can't find where those functions are defined.

    To fix this, tell gcc where libssl is installed on your machine and to link with libssl.

    e.g. gcc -o test test.c -lssl -L/usr/local/ssl/lib

    (replace /usr/local/ssl/lib with whereever libssl.so or libssl.a is placed)

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • TwistedJesterTwistedJester Registered User regular
    edited February 2009
    Ok, so I found libssl.so and libssl.a on the machine, but adding those flags just bring up a lot of other "undefined references" in /usr/lib/libssl.so, in addition to the other undefined references from before.

    TwistedJester on
  • ecco the dolphinecco the dolphin Registered User regular
    edited February 2009
    Actually, in hindsight, I think the proper way to do it is via pkg-config on Linux... but it looks like you're running cygwin?

    Try typing:

    pkg-config openssl --libs

    to see if that does anything. Mine gives me the output:

    -L/usr/local/ssl/lib -lssl -lcrypto -ldl

    If it gives a similar output on your machine, then type:

    gcc -o test test.c `pkg-config openssl --libs`

    Otherwise, try:

    gcc -o test test.c -L/usr/lib -lssl -lcrypto -ldl

    Wow. Aren't dependencies fun?

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • TwistedJesterTwistedJester Registered User regular
    edited February 2009
    Typing pkg-config openssl --libs gives me "gnome-config: not found" and other stuff saying that the package is not in the search path.

    However, I tried the last thing line you gave without the -ldl and it worked fine.

    And I just now remembered he gave us a Makefile, which of course has all of this stuff in it. Go me.

    Regardless, thanks a lot for the help.

    TwistedJester on
Sign In or Register to comment.