You forgot to specify -L/opt/local/lib, so while it's reading the 1.0.1c 
headers, it's finding lion's built in 0.9.8 library.

Bob

On 4 Jul 2012, at 18:29, mmdon...@aol.com wrote:

> MacBook 2,1 Mac OS X 10.7.4 Xcode 4.3.3
> 
> MacPorts    openssl @1.0.1c_0 (active)
> 
> 
> When I attempt to compile the example at
> 
> http://www.openssl.org/docs/crypto/EVP_DigestInit.html
> 
> using
> 
> gcc -Wall -I /opt/local/include -o mdtest mdtest.c 
> 
> I get the following errors from gcc:
> 
> Undefined symbols for architecture x86_64:
>   "_OpenSSL_add_all_digests", referenced from:
>       _main in cc2OLVyU.o
>   "_EVP_get_digestbyname", referenced from:
>       _main in cc2OLVyU.o
>   "_EVP_MD_CTX_create", referenced from:
>       _main in cc2OLVyU.o
>   "_EVP_DigestInit_ex", referenced from:
>       _main in cc2OLVyU.o
>   "_EVP_DigestUpdate", referenced from:
>       _main in cc2OLVyU.o
>   "_EVP_DigestFinal_ex", referenced from:
>       _main in cc2OLVyU.o
>   "_EVP_MD_CTX_destroy", referenced from:
>       _main in cc2OLVyU.o
> ld: symbol(s) not found for architecture x86_64
> collect2: ld returned 1 exit status
> 
> When I grep for EVP_MD_CTX_create in /opt/local/include/openssl/evp.h
> it is found,  but not with the leading underscore, the same is true for
> the other "undefined symbols" above.
> 
> I have tried changing architecture to i386 and compiler
> to cc, but results are the same.
> 
> Any info would be appreciated.
> 
> Thanks,
> mmdonley
> ==================================================
> The example to which I refer is included herein. Two minor
> revisions were necessary: (1) include string.h and (2) change
> md_len to an unsigned int:
> 
> #include <stdio.h>
> #include <string.h>
> #include <openssl/evp.h>
> 
> int main(int argc, char *argv[])
> {
>  EVP_MD_CTX *mdctx;
>  const EVP_MD *md;
>  char mess1[] = "Test Message\n";
>  char mess2[] = "Hello World\n";
>  unsigned char md_value[EVP_MAX_MD_SIZE];
>  unsigned md_len, i;
>  OpenSSL_add_all_digests();
>  if(!argv[1]) {
>         printf("Usage: mdtest digestname\n");
>         exit(1);
>  }
>  md = EVP_get_digestbyname(argv[1]);
>  if(!md) {
>         printf("Unknown message digest %s\n", argv[1]);
>         exit(1);
>  }
>  mdctx = EVP_MD_CTX_create();
>  EVP_DigestInit_ex(mdctx, md, NULL);
>  EVP_DigestUpdate(mdctx, mess1, strlen(mess1));
>  EVP_DigestUpdate(mdctx, mess2, strlen(mess2));
>  EVP_DigestFinal_ex(mdctx, md_value, &md_len);
>  EVP_MD_CTX_destroy(mdctx);
>  printf("Digest is: ");
>  for(i = 0; i < md_len; i++) printf("%02x", md_value[i]);
>  printf("\n");
> 
>  return 0;
> }
> 

Reply via email to