Problem compiling GMP code

This is a discussion on Problem compiling GMP code within the C Programming forums, part of the General Programming Boards category; Hi all! As I said in a previous post, I'm working with HUGE numbers, and it was suggested to me ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    3

    Unhappy Problem compiling GMP code

    Hi all!

    As I said in a previous post, I'm working with HUGE numbers, and it was suggested to me to try GMP.

    I have installed it on /usr/local/gmp-4.1.4 (with "./configure" and then "make") as it was said to be de default location. The installing procedures seemed to be ok. The validation tests were fine too.

    So, I've wrote the following test.c file:

    Code:
    #include <stdio.h>
    #include <gmp.h>
    
    int main (){
    
    mpz_t i;
    
    return;
    }
    At first, I tried to compile with
    gcc -o test test.c -lgmp
    but I got a "gmp.h - File not found"

    Then, I tried
    gcc -o test test.c -I /usr/local/gmp-4.1.4 -lgmp
    and
    gcc -o test test.c -I /usr/local/gmp-4.1.4 -L /usr/local/gmp-4.1.4 -lgmp
    and
    gcc -o test test.c -I /usr/local/gmp-4.1.4/ -L /usr/local/gmp-4.1.4/lib -lgmp

    but for all of them I got a "cannot find -lgmp"

    As you can probably see, I'm not a C expert, so I would like to apologize if I am doing something obviously wrong. But the fact is that I am not able to simply compile that code...

    PLEASE, HELP!!!

    Thanks in advance,

    Bruno
    Last edited by Bruno Couto; 10-07-2005 at 07:17 AM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,671
    You could check your /usr/local/gmp-4.1.4/lib to see if there are indeed any libraries at all in that directory.

    I prefer specifying paths before files
    gcc -I/usr/local/gmp-4.1.4/ -L/usr/local/gmp-4.1.4/lib -o test test.c -lgmp

    The command syntax is right, I think all you need is to find where the file is, and what it's name is.

    Also, FYI, calling your program 'test' is a bad idea since there is a shell command by the same name.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    Code:
    return;
    I don't think you can do that from a function that returns int. Put
    Code:
    return 0;
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with compiling code in cygwin
    By firyace in forum C++ Programming
    Replies: 4
    Last Post: 06-01-2007, 08:16 AM
  2. code problem
    By maritos in forum C Programming
    Replies: 1
    Last Post: 11-27-2005, 04:22 PM
  3. problem with selection code
    By DavidP in forum Game Programming
    Replies: 1
    Last Post: 06-14-2004, 01:05 PM
  4. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM
  5. Help with code for simple Y2K problem
    By Mule in forum C++ Programming
    Replies: 3
    Last Post: 03-05-2003, 11:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21