title: Unable to link tomsfastmath into libtomcrypt
body: <p>I am writing a secure instant messaging program in c++ using the libtomcrypt C library for its RSA and SPRNG functions. I got libtomcrypt compiled as a static library and I have been able to link to it and run the sprng functions and see and use the random data it is generating. </p>
  
  <p>The problem I am having is trying to use the rsa_make_key() function which has dependencies to a linked math library to function. </p>
  
  <p>In this case I am trying to use Tomsfastmath (tfm) which I am also trying to link as a static library. Both of these libraries reside in their own project folder one directory up from my project folder (ie ../libtomcrypt) </p>
  
  <p>In my code when I try to access the tomsfast math descriptor "tfm_desc" I get the error <code>test_crypt.cpp:8:11: error: 'tfm_desc' was not declared in this scope</code>. Which makes me think that tfm is not getting correctly linked into libtomcrypt. I have read the documentation for both of these things its not very clear. </p>
  
  <p>I am at wits end here.  What I am doing wrong? </p>
  
  <p>Here is my make file </p>
  
  <pre><code> CC:=gcc #C Compiler
   CFLAGS:=-std=c99 -O0 -I/home/k3rb3ros/csci484-CMU-/libtomcrypt-1.17/src/headers -g -     Wall -Wextra#C Compiler flags
   CPP:=g++ #C++ Compiler
   CPPFLAGS:=-std=gnu++0x -O0 -I/home/k3rb3ros/csci484/csci484-CMU-/libtomcrypt-  1.17/src/headers -L. -g -Wall -Wextra#C++ Compiler flags
   #CPPFLAGS:=-std=gnu++0x -O0 -g -Wall -Wextra #C++ Compiler flags
   LDFLAGS:= -lSDL -lSDL_net -ltfm -ltomcrypt
   CSOURCES= #C files used in this program
   CPPSOURCES=connection.cpp chat.cpp test_crypt.cpp #CPP files used in this prgram
   #COBJECTS=$(CSOURCES:.c=.o)libtfm.a libtomcrypt.a
   COBJECTS=$(CSOURCES:.c=.o)
   CPPOBJECTS=$(CPPSOURCES:.cpp=.o)
   BINARY=down_low
  
   all: $(BINARY) $(COBJECTS) $(CPPOBJECTS)
   .c.o:
        $(CC) $(CFLAGS) -c $&lt; -o $@
  
   .cpp.o:
        $(CPP) $(CPPFLAGS) -c $&lt; -o $@
  
    $(BINARY): $(COBJETS) $(CPPOBJECTS)
        $(CPP) $(CPPFLAGS) $(COBJECTS) $(CPPOBJECTS) -o $@ $(LDFLAGS)
  
    clean:
       rm -rv $(BINARY) $(COBJECTS) $(CPPOBJECTS)
  </code></pre>
  
  <p>and here is my test_crypt function </p>
  
  <pre><code>#include "headers/test_crypt.h"
  using namespace std;
  
  void test_crypt()
  {
       int err = 0;
       int rng_idx = -1; //rng index, not sure if I need this
       ltc_mp = tfm_desc; //tell tomcrypt to use toms fast math
       rsa_key pub_key;
       prng_state random_gen;
  
       if((err = sprng_start(&amp;random_gen)) != CRYPT_OK) //start the rng and check for errors
       {
           cout &lt;&lt; "start error " &lt;&lt; error_to_string(err) &lt;&lt; endl;
       }
  
       rng_idx = find_prng("sprng");
       if((err = sprng_ready(&amp;random_gen)) != CRYPT_OK)
       {
           cout &lt;&lt; "Ready error " &lt;&lt; error_to_string(err) &lt;&lt; endl;
       }
  
       //test toms fast math present and working
       //fp_int test;
       //fp_init(&amp;test);
  
       //sprng_read(entropy, size, &amp;random_gen);
  
       /*
       if((err = rsa_make_key(NULL,           //PRNG state
                              rng_idx,        //PRNG idx
                              1024/8,         //Size of key
                              65537,          //e
                              &amp;pub_key)       //RSA key
                              ) != CRYPT_OK) //if conditon test
       {
           cout &lt;&lt; "RSA Key Generation error " &lt;&lt; error_to_string(err) &lt;&lt; endl;
       }
       rsa_free(&amp;pub_key); //free the key when we are done with it;
       */
       sprng_done(&amp;random_gen); //done generating random numbers
  }
  </code></pre>