Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Jak dodać bibliotekę GMP w DEV C++

Ostatnio zmodyfikowano 2016-04-03 10:54
Autor Wiadomość
mateczek
» 2016-03-31 17:22:02
Nie wiem, o czym piszesz. Nie miałem żadnych problemów przy kompilacji tej biblioteki.
ja też nie miałem (na początku cygwin się stawiał odnośnie symlinków)  Spróbuje skompilować jeszcze raz do static i sprawdzę czy działa.  Jeśli tak. to koledze podeśle się najwyżej skompilowaną(choć podejrzewam, że problemy z dodaniem do projektu będą bo ja mam mingw32 a kolega jakiś inny kompilator chyba )

http://chomikuj.pl/mysiadziura​/www.marekk.dreamhosters.com​/instal,5315752080.7z(archive)

tutaj biblioteka w wersji: gmp-6.1.0 skompilowana przy pomocy
mingw492_32 - kompilator dostarczony wraz z pakietem qt-opensource-windows-x86-mingw492-5.5.1.exe

jedyna flaga to wsparcie dla c++ ./configure --enable-cxx

tutaj jak ja dodałem do projektu skompilowaną bibliotekę - jako bibliotekę zewnętrzną
http://chomikuj.pl/mysiadziura​/www.marekk.dreamhosters.com​/biblioteka_gmp,5315784165.odp

Program który skompilowałem przy pomocy tej biblioteki to

C/C++
#include <iostream>
#include <gmpxx.h>
using namespace std;

int main() {
    mpz_class a, b, c;
   
    a = 1234;
    b = "-5678";
    c = a + b;
    cout << "sum is " << c << "\n";
    cout << "absolute value is " << abs( c ) << "\n";
   
}
//przykładowy kod


ps. W filmie na ubuntu ja nie kompilowałem bibliotek tylko je instalowałem w wersji skompilowanej !!! Biblioteki te są kompilowane przez opiekunów pakietów. To są fachowcy, którzy się na tym znają o wiele lepiej niż ja (jakie opcje, jakie flagi,  itp itd )
P-146831
osobliwy_nick
Temat założony przez niniejszego użytkownika
» 2016-03-31 18:37:50
Chyba się skompilowało prawidłowo. Najpierw wpisałem "./configure", nie dało się wpisać "make" zaraz pod tym. Gdy program skończył wypisał jakieś parametry i wersję chyba jakiegoś programu na samym końcu. Po czym wpisałem "make" i proces zakończył się na tym:

libtool: link: ln mpn/remove.o .libs/libgmp.lax/lt105-remove.o || cp mpn/remove.o .libs/libgmp.lax/lt105-remove.o
libtool: link: ar cq .libs/libgmp.a @.libs\\libgmp.libcmd
libtool: link: ranlib .libs/libgmp.a
libtool: link: rm -fr .libs/libgmp.lax
libtool: link: ( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )
make[2]: Leaving directory `/c/GMP/gmp-6.1.0'
make[1]: Leaving directory `/c/GMP/gmp-6.1.0'

Wszystko trwało chyba kilkanaście minut. Mam rozumieć, że skompilowało się prawidłowo?
P-146833
mateczek
» 2016-03-31 18:43:07
./configure --enable-cxx
inaczej nie będziesz miał c++ tylko czyste C
i przed ponownym make warto (nawet trzeba) uruchomić

make clean
P-146834
osobliwy_nick
Temat założony przez niniejszego użytkownika
» 2016-03-31 19:03:32
Ok, więc robię wszystko jeszcze raz. Mam nadzieję, że tym razem tak to miało przebiegać (przynajmniej dla wersji C).

Zakładając, że wszystko się skompiluje, to poza dodaniem "#include <gmpxx.h>" w kodzie i nowym zadeklarowaniem zmiennych coś jeszcze należy zrobić, żeby korzystać z tej biblioteki. Podawać znów gdzieś jakieś ścieżki?

Edit: komenda ./configure --enable-cxx zakończyła się:

config.status: executing libtool commands
configure: summary of build options:

  Version:           GNU MP 6.1.0
  Host type:         silvermont-pc-mingw32
  ABI:               32
  Install prefix:    /usr/local
  Compiler:          gcc -std=gnu99
  Static libraries:  yes
  Shared libraries:  no

A komenda "make":

$ make
make  all-recursive
make[1]: Entering directory `/c/GMP/gmp-6.1.0'
Making all in tests
make[2]: Entering directory `/c/GMP/gmp-6.1.0/tests'
Making all in .
make[3]: Entering directory `/c/GMP/gmp-6.1.0/tests'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/tests'
Making all in devel
make[3]: Entering directory `/c/GMP/gmp-6.1.0/tests/devel'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/tests/devel'
Making all in mpn
make[3]: Entering directory `/c/GMP/gmp-6.1.0/tests/mpn'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/tests/mpn'
Making all in mpz
make[3]: Entering directory `/c/GMP/gmp-6.1.0/tests/mpz'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/tests/mpz'
Making all in mpq
make[3]: Entering directory `/c/GMP/gmp-6.1.0/tests/mpq'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/tests/mpq'
Making all in mpf
make[3]: Entering directory `/c/GMP/gmp-6.1.0/tests/mpf'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/tests/mpf'
Making all in rand
make[3]: Entering directory `/c/GMP/gmp-6.1.0/tests/rand'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/tests/rand'
Making all in misc
make[3]: Entering directory `/c/GMP/gmp-6.1.0/tests/misc'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/tests/misc'
Making all in cxx
make[3]: Entering directory `/c/GMP/gmp-6.1.0/tests/cxx'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/tests/cxx'
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/tests'
Making all in mpn
make[2]: Entering directory `/c/GMP/gmp-6.1.0/mpn'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/mpn'
Making all in mpz
make[2]: Entering directory `/c/GMP/gmp-6.1.0/mpz'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/mpz'
Making all in mpq
make[2]: Entering directory `/c/GMP/gmp-6.1.0/mpq'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/mpq'
Making all in mpf
make[2]: Entering directory `/c/GMP/gmp-6.1.0/mpf'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/mpf'
Making all in printf
make[2]: Entering directory `/c/GMP/gmp-6.1.0/printf'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/printf'
Making all in scanf
make[2]: Entering directory `/c/GMP/gmp-6.1.0/scanf'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/scanf'
Making all in rand
make[2]: Entering directory `/c/GMP/gmp-6.1.0/rand'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/rand'
Making all in cxx
make[2]: Entering directory `/c/GMP/gmp-6.1.0/cxx'
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o isfuns.lo isfuns.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c isfuns.cc -o isfuns.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o ismpf.lo ismpf.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c ismpf.cc -o ismpf.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o ismpq.lo ismpq.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c ismpq.cc -o ismpq.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o ismpz.lo ismpz.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c ismpz.cc -o ismpz.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o ismpznw.lo ismpznw.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c ismpznw.cc -o ismpznw.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o limits.lo limits.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c limits.cc -o limits.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o osdoprnti.lo osdoprnti.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c osdoprnti.cc -o osdoprnti.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o osfuns.lo osfuns.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c osfuns.cc -o osfuns.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o osmpf.lo osmpf.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c osmpf.cc -o osmpf.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o osmpq.lo osmpq.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c osmpq.cc -o osmpq.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMPXX -I..   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o osmpz.lo osmpz.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c osmpz.cc -o osmpz.o
/bin/sh ../libtool  --tag=CXX   --mode=link g++  -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm   -o libcxx.la  isfuns.lo ismpf.lo ismpq.lo ismpz.lo ismpznw.lo limits.lo osdoprnti.lo osfuns.lo osmpf.lo osmpq.lo osmpz.lo
libtool: link: ar cq .libs/libcxx.a  isfuns.o ismpf.o ismpq.o ismpz.o ismpznw.o limits.o osdoprnti.o osfuns.o osmpf.o osmpq.o osmpz.o
libtool: link: ranlib .libs/libcxx.a
libtool: link: ( cd ".libs" && rm -f "libcxx.la" && ln -s "../libcxx.la" "libcxx.la" )
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/cxx'
Making all in demos
make[2]: Entering directory `/c/GMP/gmp-6.1.0/demos'
Making all in calc
make[3]: Entering directory `/c/GMP/gmp-6.1.0/demos/calc'
make  all-am
make[4]: Entering directory `/c/GMP/gmp-6.1.0/demos/calc'
make[4]: Nothing to be done for `all-am'.
make[4]: Leaving directory `/c/GMP/gmp-6.1.0/demos/calc'
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/demos/calc'
Making all in expr
make[3]: Entering directory `/c/GMP/gmp-6.1.0/demos/expr'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/demos/expr'
make[3]: Entering directory `/c/GMP/gmp-6.1.0/demos'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/c/GMP/gmp-6.1.0/demos'
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/demos'
Making all in tune
make[2]: Entering directory `/c/GMP/gmp-6.1.0/tune'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/tune'
Making all in doc
make[2]: Entering directory `/c/GMP/gmp-6.1.0/doc'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/GMP/gmp-6.1.0/doc'
make[2]: Entering directory `/c/GMP/gmp-6.1.0'
/bin/sh ./libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.  -D__GMP_WITHIN_GMP   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c -o dummy.lo `test -f 'cxx/dummy.cc' || echo './'`cxx/dummy.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -D__GMP_WITHIN_GMP -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm -c cxx/dummy.cc -o dummy.o
/bin/sh ./libtool  --tag=CXX   --mode=link g++  -m32 -O2 -pedantic -fomit-frame-pointer -mtune=slm -march=slm   -version-info 9:0:5  -o libgmpxx.la -rpath /usr/local/lib dummy.lo cxx/isfuns.lo cxx/ismpf.lo cxx/ismpq.lo cxx/ismpz.lo cxx/ismpznw.lo cxx/limits.lo cxx/osdoprnti.lo cxx/osfuns.lo cxx/osmpf.lo cxx/osmpq.lo cxx/osmpz.lo libgmp.la
libtool: warning: undefined symbols not allowed in silvermont-pc-mingw32 shared libraries; building static only
libtool: link: ar cq .libs/libgmpxx.a  dummy.o cxx/isfuns.o cxx/ismpf.o cxx/ismpq.o cxx/ismpz.o cxx/ismpznw.o cxx/limits.o cxx/osdoprnti.o cxx/osfuns.o cxx/osmpf.o cxx/osmpq.o cxx/osmpz.o
libtool: link: ranlib .libs/libgmpxx.a
libtool: link: ( cd ".libs" && rm -f "libgmpxx.la" && ln -s "../libgmpxx.la" "libgmpxx.la" )
make[2]: Leaving directory `/c/GMP/gmp-6.1.0'
make[1]: Leaving directory `/c/GMP/gmp-6.1.0'

Dobrze się skompilowało?
P-146835
mateczek
» 2016-03-31 19:09:40
Zakładając, że wszystko się skompiluje, to poza dodaniem "#include <gmpxx.h>" w kodzie i nowym zadeklarowaniem zmiennych (...)

oczywiście, że tak.

zrobiłem Ci krótką prezentację w PowerPoincie(libreOffice) jak to u mnie wyglądało !!! dodanie zewnętrznej biblioteki


http://chomikuj.pl/mysiadziura​/www.marekk.dreamhosters.com​/biblioteka_gmp,5315784165.odp

2. opcja to po-kopiować pliki do katalogów twojego kompilatora. lib include :P. Proste życie  to tylko na Ubuntu :P
P-146836
osobliwy_nick
Temat założony przez niniejszego użytkownika
» 2016-03-31 19:35:47
A programy, które mam do kompilacji mam kompilować w Dev C++, czy też za pomocą MSYS? Nie mogę niczego skompilować jak na razie w Dev C++. Mam błąd:

[Error] gmpxx.h: No such file or directory
P-146838
j23
» 2016-03-31 20:02:31
Swoje własne programy możesz kompilować w IDE jakim chcesz. Ale przygotuj się na to, że większość bibliotek będziesz kompilował przy użyciu MSYS/Cygwin, CMAKE czy plików makefile odpalanych konsoli (po to ustawiasz zmienną PATH).

[Error] gmpxx.h: No such file or directory
Do projektu musisz dodać ścieżki do katalogu z nagłówkami i katalogu z plikiem .a. No i oczywiście musisz dodać plik biblioteki.
P-146839
osobliwy_nick
Temat założony przez niniejszego użytkownika
» 2016-03-31 20:23:47
Katalog z nagłówkami i katalog z plikiem .a. są w katalogu, w której jest cała biblioteka? Który to katalog z nagłówkami i jak znaleźć plik .a.?

A gdzie szukać pliku biblioteki i jaką ma nazwę?

Rozumiem, że katalog z nagłówkami, katalog z plikiem .a. i sam plik mam dodać tak jak to opisano tu:

http://cpp0x.pl/artykuly/?id=49

P-146841
1 2 3 4 « 5 » 6 7 8
Poprzednia strona Strona 5 z 8 Następna strona