mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Software

Reply
 
Thread Tools
Old 2022-08-24, 14:52   #1
Deuterium
 
Deuterium's Avatar
 
Sep 2020

5 Posts
Default GMP Library and C IDE

Guys, I need your help because I cannot find the end of this nightmare.


Target : use an easy C IDE in order to develop a software that invilves big numbers, through the library GMP


Software used : CodeLite IDE


--------------------------------------------


Issues : I downloaded the GMP library package (6.2.1) and I cannot literally use it.
I am working under Windows 10.
Basically I unzipped the gmp package into my desktop and this is my program :


Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>

#include  "C:\Users\davin\Desktop\gmp-6.2.1\gmpxx.h"

int main()
{
    int i;
    mpz_t a;
    
    printf("hello world\n");

    return 0;
}



First : Why the header should be GMP.H and it is not present ? I see only GMPXX.H and I am using C, not C++


Second : I try to build and I get an error that says that the library "iosfwd" is not present. This error is inside the gmpxx.h




I haven't found any way to get the rid of this... Why is it so complicated to use a library with a normal IDE ?


Thanks in advance for your help
Deuterium is offline   Reply With Quote
Old 2022-08-24, 21:09   #2
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

2·32·653 Posts
Default

I can't help you with Windows-specific stuff, but just looking at one of my Intel/Linux boxes where I compile and run GMP-using C code:
Code:
ls -l /usr/include/gmp*
-rw-r--r-- 1 root root 116607 Dec  1  2018 /usr/include/gmpxx.h
ls -l /usr/include/*/gmp*
-rw-r--r-- 1 root root 83776 Dec  1  2018 /usr/include/x86_64-linux-gnu/gmp.h
So the requisite gmp.h is there, it's just one dir deeper than gmpxx.h, meaning that standard header-file processing should find it. Change gmpxx.h to gmp.h and see if you can compile.
ewmayer is offline   Reply With Quote
Old 2022-08-25, 09:39   #3
ccorn
 
ccorn's Avatar
 
Apr 2010

5×31 Posts
Default

gmpxx.h is GMP's C++ wrapper. It includes further C++ headers which a C compiler is not meant to be able to find or use.
Therefore the message about not finding iosfwd. You want gmp.h instead.

If I recall correctly, gmp.h is created only after you have run GMP's configure script.
Then the GMP library itself needs to be built. Only then you will be able to link with it.
ccorn is offline   Reply With Quote
Old 2022-08-25, 10:06   #4
ccorn
 
ccorn's Avatar
 
Apr 2010

9B16 Posts
Default

Just in case: If you wonder how to run GMP's configure script under Windows:
If you use Git for Windows (and you should), that comes with a lot of Unix-y tools (bash, coreutils, perl etc).

So you can run GMP's configure from the Git bash prompt.
ccorn is offline   Reply With Quote
Old 2022-08-26, 04:13   #5
casevh
 
Dec 2005

52 Posts
Default

It looks like CodeLite is based on (or can use) MSYS2 and the MinGW64 compiler suite. There is documentation on their website:

https://docs.codelite.org/build/mingw_builds/

A pre-compiled GMP library can be downloaded inside MSYS2. Install MSYS2 as documented on the link. The command to download the required files for GMP is "pacman -Sy libgmp-dev". If that doesn't work, let me know.

casevh
casevh is offline   Reply With Quote
Old 2022-08-27, 00:20   #6
casevh
 
Dec 2005

1916 Posts
Default

I have it working. Here are the steps I followed.

1. Install the CodeLite IDE.

2. Follow the instructions at https://docs.codelite.org/build/mingw_builds/ to install the mingw-w64 compilers. The exact steps are:

2.1. Install MSYS2
2.2. At first start of the MSYS2 terminal, run "pacman -Syuu"
2.3. At second start of the MSYS2 terminal run the "pacman -Sy mingw ..." command from the web page.

3. Start CodeLite and update the Build settings to use the compiler provided by MSYS2. https://docs.codelite.org/settings/build_settings/

The path for the compiler is C:/msys64/mingw64

I created a project with the main.c as

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>

#include  <gmp.h>

int main()
{
    int i;
    mpz_t a;
    
    printf("hello world\n");

    return 0;
}
It compiled successfully.

casevh
casevh is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
OPN Library website ThomRuley Factoring 9 2021-01-04 13:40
error with gmp-ecm library bhelmes Software 2 2020-04-30 20:21
Using YAFU as a C-library LangerJan YAFU 2 2013-02-17 06:18
Quickest fft library nuggetprime Software 3 2011-01-09 01:24
GWNUM library bearnol Software 6 2006-02-24 11:19

All times are UTC. The time now is 00:20.


Wed Nov 30 00:20:57 UTC 2022 up 103 days, 21:49, 0 users, load averages: 1.51, 1.13, 0.98

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔