Thread: how do I use/install libtommath?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    36

    how do I use/install libtommath?

    I downloaded libtommath zip file
    Now how do I start using it?
    I am using gcc in windows 7
    Please help
    Thank you very much

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    36
    I suppose I could start by making a project, including all the files in libtommath in that project and hitting build
    But I have another problem
    I also downloaded tomsfastmath libraryfrom the same website, and it includes projects for Visual C and Visual Studio 2005 and 2008. I imported them to codeblocks and hit build. All the files compile properly, but at the end I get a message saying "You must select host application to run a library". What does this mean?
    Attached Images Attached Images how do I use/install libtommath?-libtommath-error-bmp 

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    In other words, you have a library, but you need to use the library in a program in order for it to be err... useful.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    36
    Yes, exactly
    Please tell me how I should start

  5. #5
    Registered User
    Join Date
    Dec 2011
    Posts
    36
    Perhaps I could look at the big number function implementations in this library and try to write my own on their basis, but that would take too long (since the library contains processor specific codes to make certain routines run faster on certain processors)
    I just want to be able to create variables that can hold large numbers, so that I can use them in my own implementation of some algorithms such as Montgomery reduction and few others

  6. #6
    Registered User
    Join Date
    Nov 2011
    Posts
    161
    The Bignum library here: The GNU MP Bignum Library
    has some good documentation on how to use it.

  7. #7
    Registered User
    Join Date
    Dec 2011
    Posts
    36
    I have already had a lot of problems trying to install it in Windows
    Moreover I don't know if it compiles in gcc, another tutorial on the web says it need to be compiled under MS VC++ 6.0
    I can at least get it to install and run a sample program in Linux but it would be much more convenient for me if I could do it in Windows 7

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    First you need to set your compiler to build a STATIC LIBRARY and compile the library itself.
    Then you use the header files .h from it like you use stdlib.h and string.h in your regular programs.

    It's not a program by itself.

  9. #9
    Registered User
    Join Date
    Dec 2011
    Posts
    36
    so how do I set my compiler to build a static library?

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by mahaju View Post
    so how do I set my compiler to build a static library?
    Geee... wouldn't be wonderful if there was some place you could look this kind of thing up? Some kind of, gosh I dunno... "Help File" or something?

  11. #11
    Registered User
    Join Date
    Dec 2011
    Posts
    36
    The last post would have been more helpful and would have saved much more time if it contained some actual references, like Creating a shared and static library with the gnu compiler [gcc] and The GNU C Programming Tutorial
    Anyway after I create the library, when trying to use it in a sample program demo.c as provided by the creators of the libtommath library this is what I get in codeblocks after I build the project


    Code:
    -------------- Build: Debug in ltm_test ---------------
    
    Compiling: demo.c
    mingw32-gcc.exe: libraries\LibTom: No such file or directory
    mingw32-gcc.exe: projects\ltm-0.42.0\ltm_library: No such file or directory
    mingw32-gcc.exe: and: No such file or directory
    mingw32-gcc.exe: headers\test\demo.c -o obj\Debug\demo.o: No such file or directory
    mingw32-gcc.exe: no input files
    Process terminated with status 1 (0 minutes, 0 seconds)
    0 errors, 0 warnings
    What does this mean? Does this mean there was a problem when the library was created or is it something else?
    Could this be possible because of some inappropriate settings in Codeblocks?
    Thanks in advance
    Last edited by mahaju; 12-28-2011 at 06:32 AM.

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by mahaju View Post
    The last post would have been more helpful and would have saved much more time if it contained some actual references, like Creating a shared and static library with the gnu compiler [gcc] and The GNU C Programming Tutorial
    And exactly how does it turn out that we are to do your work for you?

    What did that take you... maybe 15 seconds on Google?

    If you have a problem or there's something you just don't understand that's one thing. But don't be criticising people how do this strictly out of kindness when they expect you to make a reasonable effort on your own.

    Really....

  13. #13
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  14. #14
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Okay, there is a makefile. You don't have to do anything to create the library:

    /libtommath-0.42.0> make

    Now there's tons of .o files around, but also, libtommath.a. I copied that into the "demo" directory (you can make the demo automatically with "make test", but we want to see how to use the lib). I also copied the "tommath.h" into there. I then had to put "tommath_class.h" and "tommath_superclass.h" into my include path. Then:

    /libtommath-0.42.0/demo> gcc libtommath.a demo.c

    Compiles fine. I'm not sure what the executable is supposed to do, but it runs.

    This is exactly the same on windows. Again, if you can understand these few simple steps, you have everything you need to use the library. Getting it to then work with codeblocks is just applying that to codeblocks, which I don't use, but you at least now have something straightforward to eg, ask someone else who does use codeblocks how to apply.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  15. #15
    Registered User
    Join Date
    Dec 2011
    Posts
    36
    Thank you very much
    I have also produced the .a file, however, I did that by compiling all the .c files in codeblocks (I wasn't sure how to combine multiple files in command line so I used Codeblocks for compiling, which has an option of making a static library project)
    The next step, linking it with the demo.c file was creating problems in codeblocks and I am still working on it

    Thank you very much for your time and effort

    Also in your code you have just entered the name of the library and c file for compiling, but I thought we needed the -l<name> parameter for linking the libraries. Also, did you just leave out the -o option in this post only or you didn't give it at all?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How I do install SDL?
    By gibbofresco in forum Game Programming
    Replies: 11
    Last Post: 09-25-2006, 10:38 PM
  2. Install
    By Scarvenger in forum C++ Programming
    Replies: 3
    Last Post: 10-24-2005, 10:33 AM
  3. DOS install
    By jrahhali in forum Tech Board
    Replies: 9
    Last Post: 03-05-2004, 01:47 AM
  4. How i must install SDL?
    By SuRaNa in forum C++ Programming
    Replies: 1
    Last Post: 12-23-2002, 02:35 AM
  5. install
    By bob20 in forum Windows Programming
    Replies: 3
    Last Post: 12-05-2002, 09:32 PM