Compile Giac on Mac OS X

Librairie C++ de calcul formel/ C++ symbolic computation library

Modérateur : xcasadmin

pemitsig
Messages : 17
Inscription : lun. nov. 29, 2010 3:26 pm

Compile Giac on Mac OS X

Message par pemitsig » jeu. déc. 02, 2010 3:57 pm

Hello,

We are two students from the greek University of Thessaly and we were currently assigned with a project in which we want to compile Giac on Mac OS.

Our system preferences:
We have two laptops. Both of them are PCs and have hackintosh on them.
Both have Intel processors.
One of them is running Mac OS X 10.5.8 and the other one 10.5.6.

Till now we tried lot of things.

Using MacPorts we installed all of the libaries we though that were nessecary:
expat @2.0.1_1 (active)
gcc43 @4.3.5_2 (active)
gettext @0.18.1.1_2 (active)
gmp @5.0.1_0 (active)
gperf @3.0.4_0 (active)
gsl @1.14_0 (active)
libiconv @1.13.1_0 (active)
libpng @1.2.44_0 (active)
mpfr @3.0.0-p8_0 (active)
ncurses @5.7_1 (active)
ncursesw @5.7_1 (active)
ntl @5.4.2_0 (active)
perl5 @5.8.9_0 (active)
perl5.8 @5.8.9_3 (active)
tcl @8.5.9_0 (active)
texinfo @4.13_2 (active)
xz @5.0.0_0 (active)
zlib @1.2.5_0 (active)

Build-in gcc compiler on our Mac OS is:
gcc version 4.0.1 (Apple Inc. build 5493)

Reading this thread we tried your suggestions:

We downloaded and extracted giac-0.8.6.tar.gz and in the folder which was created we wrote these commands in the terminal:

Code : Tout sélectionner

export CFLAGS='-O2 -I/usr/local/include-arch i386-Set to be -L/usr/local/lib /Developer/SDKs/MacOSX10.4u.sdk-mmacosx-version-min = 10.4'
export CXXFLAGS=$CFLAGS
export MACOSX_DEPLOYMENT_TARGET='10.5'
export CC='/usr/bin/gcc4.0'
export CXX='/usr/bin/g++4.0'
After all the exports we execute:

Code : Tout sélectionner

sudo ./configure
Everything ran smoothly till this point with the exception that after ./configure command the terminal stops working properly. Any sudo command after this returns an "illegal operation" message and doesn't execute. After this misbehavior of the terminal we perform a reboot which brings the terminal back to a working state and then we continue by executing:

Code : Tout sélectionner

sudo make
which returns these errors in the terminal:

Code : Tout sélectionner

make  all-recursive
Making all in src
/bin/sh ../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I.. -I. -I..    -g -O2 -c sym2poly.cc
g++ -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -g -O2 -c sym2poly.cc -o sym2poly.o
echo timestamp > sym2poly.lo
/bin/sh ../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I.. -I. -I..    -g -O2 -c gausspol.cc
g++ -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -g -O2 -c gausspol.cc -o gausspol.o
threaded.h: In function 'void giac::type_operator_plus_times(const giac::my_mpz&, const giac::my_mpz&, giac::my_mpz&)':
threaded.h:189: error: 'mpz_addmul' was not declared in this scope
threaded.h: In function 'void giac::type_operator_plus_times_reduce(const giac::my_mpz&, const giac::my_mpz&, giac::my_mpz&, int)':
threaded.h:194: error: 'mpz_addmul' was not declared in this scope
gausspol.cc: In function 'giac::gen giac::ichrem_smod(__mpz_struct (*)[1], __mpz_struct (*)[1], __mpz_struct (*)[1], __mpz_struct (*)[1], const giac::gen&, const giac::gen&)':
gausspol.cc:424: error: 'mpz_addmul' was not declared in this scope
gausspol.cc: In function 'giac::gen giac::ichrem_smod(__mpz_struct (*)[1], __mpz_struct (*)[1], __mpz_struct (*)[1], __mpz_struct (*)[1], longlong, longlong)':
gausspol.cc:448: error: 'mpz_addmul' was not declared in this scope
gausspol.cc: In function 'giac::gen giac::ichrem_smod(const giac::gen&, const giac::gen&, const giac::gen&, const giac::gen&)':
gausspol.cc:487: error: 'mpz_addmul' was not declared in this scope
make[2]: *** [gausspol.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive-am] Error 2
Beside this attempt we also tried compliling giac-0.9.0 both frozen and unstable version using these exports:

Code : Tout sélectionner

export CXXFLAGS=-I/usr/local/include 
export CXXFLAGS=-L/usr/local/lib
export CFLAGS=-I/usr/local/include 
export CFLAGS=-L/usr/local/lib
After the exports we execute:

Code : Tout sélectionner

sudo ./configure
This returns an error message "GMP version is way too old" despite the fact that we tried compiling also with GMP 5.0.1, GMP 4.3.1 and GMP 3.1 installed.

Thanks for reading our long post, and we are looking forward hearing any suggestions.

Regards,
Petros and Filio.

parisse
Messages : 5882
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Compile Giac on Mac OS X

Message par parisse » jeu. déc. 02, 2010 7:22 pm

Hi,
I'm afraid that using gcc 4.0 will lead to problems. This is the version of gcc I have on the mac I have access to, and I could not compile giac 0.9.0 correctly last time I checked.
Another problems might come from using precompiled versions of the libraries and especially gmp 5 (I did not test against version 5). I would suggest to first compile gmp 4 *yourself* and install it with sudo make install (this will install it to /usr/local(/lib). You don't need to install other libraries at first, only gmp is mandatory.
For the configure problem, I have no idea, it always worked smoothly on the mac I compiled giac-0.8.6.
For the error: 'mpz_addmul' was not declared in this scope, it means that the gmp version which is recognized is too old. I guess it is using a /usr/include/gmp.h header installed by the MacOS system, and not your gmp 5.0 header (unless gmp is not upward compatible which would be strange), your gmp 5.0 header is most certainly installed in a custom include directory (I don't know what directory structure MacPorts is using, if you find the information, you can replace /usr/local in /usr/local/include or /usr/local/lib by the correct directory).
I also suggest you not to use -O2 compile flag at first in CFLAGS (it will compile faster).
I hope it will help you make some progresses in this compilation challenge!

pemitsig
Messages : 17
Inscription : lun. nov. 29, 2010 3:26 pm

Re: Compile Giac on Mac OS X

Message par pemitsig » dim. déc. 05, 2010 7:58 am

Hello again,

Thanks for the quick response.
After reading your advice, we have tried to compile gmp-4.2.4 ourselves using gcc-4.2 instead of Apple's gcc-4 and we made sure that we ran sudo install as well at the end.

We had no errors.
Afterwards we tried to compile giac-8.0.6 using these commands:

Code : Tout sélectionner

export CC='/usr/bin/gcc4.2'
export CXX='/usr/bin/g++4.2'
export CXXFLAGS=-I/usr/local/include 
export CXXFLAGS=-L/usr/local/lib
export CFLAGS=-I/usr/local/include 
export CFLAGS=-L/usr/local/lib
sudo ./configure
This time our terminal didn't crash so we continue without performing restart.

Code : Tout sélectionner

sudo make
but we received these errors:

Code : Tout sélectionner

...
g++ -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -g -O2 -c tex.cc -o tex.o
echo timestamp > tex.lo
/bin/sh ../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I.. -I. -I..    -g -O2 -c global.cc
g++ -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -g -O2 -c global.cc -o global.o
global.cc: In function 'bool giac::my_isnan(double)':
global.cc:2992: error: '__isnand' was not declared in this scope
global.cc: In function 'bool giac::my_isinf(double)':
global.cc:3000: error: '__isinfd' was not declared in this scope
make[2]: *** [global.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive-am] Error 2
What are we doing wrong?

parisse
Messages : 5882
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Compile Giac on Mac OS X

Message par parisse » dim. déc. 05, 2010 8:22 am

Please try to replace __isnand by isnand or _isnand, same for __isinfd by isinfd or _isinfd in the global.cc file, and let us know if it works.

pemitsig
Messages : 17
Inscription : lun. nov. 29, 2010 3:26 pm

Re: Compile Giac on Mac OS X

Message par pemitsig » mer. déc. 08, 2010 6:01 pm

Hello,

We changed __isnand to isnand and __isinfd to isinfd, we did the same exports and the ./configure again but the errors didn't go away.
We also tried changing to _isnand and _isinfd but the result was again the same.

We searched the two words isnand, isinfd in various folders so we can include the right .h but we didn't find neither of them.

At the start of global.cc file we saw this comment: "/* -*- compile-command: "g++-3.4 -I.. -g -c global.cc" -*- */"

Should we try to install gcc-3.4 and compile giac with that?

Thanks,
Filio kai Petros

parisse
Messages : 5882
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Compile Giac on Mac OS X

Message par parisse » mer. déc. 08, 2010 6:51 pm

Oops, sorry, should have been isnan and isinf or _isnan and _isinf (without d). You do not need to rerun configure, just type make after you have saved the files (that way you'll see immediatly if it works). If none of this works, you can try a trick like

Code : Tout sélectionner

bool my_isinf(double d){
   double x=0.0;
    return d==1.0/x || d==-1.0/x;
}

bool my_isnan(double d){
   double x=0.0,y=0.0;
  return d==x/y;
}

pemitsig
Messages : 17
Inscription : lun. nov. 29, 2010 3:26 pm

Re: Compile Giac on Mac OS X

Message par pemitsig » mer. déc. 08, 2010 8:38 pm

Hello again,

This time we replaced __isnand and __isinfd with isnan and isinf. We ran sudo make again and this time returned an error about libintl.h. We fixed this as well by replacing in ./libintl.h:3 the path /usr/local/include with /sw/include.

After this we ran make again and this time returned these errors:

Code : Tout sélectionner

ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [icas] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive-am] Error 2
How do we proceed?

Filio and Petros

parisse
Messages : 5882
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Compile Giac on Mac OS X

Message par parisse » mer. déc. 08, 2010 9:00 pm

I could not make work the Makefile auto-produced by configure. At this step I'm using a shell script named mkstat to produce the icas executable, edit it to include only the libraries that you are compiling against and type
sh mkstat
then run make again, you should get the same kind of error when compiling xcas, at that point I'm using another script:
sh mkhist

pemitsig
Messages : 17
Inscription : lun. nov. 29, 2010 3:26 pm

Re: Compile Giac on Mac OS X

Message par pemitsig » ven. déc. 10, 2010 5:07 pm

Hello,

We followed your instructions and did this:

Code : Tout sélectionner

cd src
sudo sh mkstat
It retrurned these errors:

Code : Tout sélectionner

powerpc-apple-darwin9-g++-4.0.1: global.o: No such file or directory
powerpc-apple-darwin9-g++-4.0.1: /usr/local/lib/libcocoa.a: No such file or directory
powerpc-apple-darwin9-g++-4.0.1: /usr/local/lib/libreadline.a: No such file or directoryi686-apple-darwin9-g++-4.0.1: global.o: No such file or directory
i686-apple-darwin9-g++-4.0.1: /usr/local/lib/libcocoa.a: No such file or directory
i686-apple-darwin9-g++-4.0.1: /usr/local/lib/libreadline.a: No such file or directory
i686-apple-darwin9-g++-4.0.1: /usr/local/lib/libhistory.a: No such file or directory
powerpc-apple-darwin9-g++-4.0.1: /usr/local/lib/libhistory.a: No such file or directory
lipo: can't figure out the architecture type of: /var/tmp//ccWPoH9Q.out
strip: can't process non-object and non-archive file: /Users/filioui/Downloads/giac-0.8.6/src/icas
So we edited the mkstat file and removed these libraries: global.o, libcocoa.a, libreadline.a, libhistory.a. We ran sudo sh mkstat again and returned this:

Code : Tout sélectionner

ld: library not found for -lcrt1.10.5.o
collect2: ld returned 1 exit status
ld: library not found for -lcrt1.10.5.o
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccQnqVo1.out (No such file or directory)
strip: can't process non-object and non-archive file: /Users/filioui/Downloads/giac-0.8.6/src/icas
Should we remove any other library? We tried to find the files lcrt1.10.5.o and ccQnqVo1.out but we couldn't. We tried sudo make again but we had no luck. Same errors!

parisse
Messages : 5882
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Compile Giac on Mac OS X

Message par parisse » ven. déc. 10, 2010 5:38 pm

global.o should not be removed. It's strange that it was not compiled.
You should also use the same version of g++ than for compiling the cc files of giac and gmp.
Note also that some options of the mkstat file may not apply for you : -arch ppc -arch i386 should be removed if you did not compile an universal binary from start.

pemitsig
Messages : 17
Inscription : lun. nov. 29, 2010 3:26 pm

Re: Compile Giac on Mac OS X

Message par pemitsig » ven. déc. 10, 2010 6:29 pm

Hello,

We put back global.o, removed -arch ppc -arch i386 and ran sh mkstat linked with g++4.2, the same one we used for gmp and giac.

It returned these errors:

Code : Tout sélectionner

ld: library not found for -lcrt1.10.5.o
collect2: ld returned 1 exit status
strip: can't open file: icas (No such file or directory)

parisse
Messages : 5882
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Compile Giac on Mac OS X

Message par parisse » ven. déc. 10, 2010 8:02 pm

Still the same error about libcrt which is not explictly linked in the command. Perhaps it has something to do with -isysroot /Developer/SDKs/MacOSX10.4u.sdk, what is a SDK you are using?

pemitsig
Messages : 17
Inscription : lun. nov. 29, 2010 3:26 pm

Re: Compile Giac on Mac OS X

Message par pemitsig » ven. déc. 10, 2010 8:52 pm

Our system is running Mac OS X 10.5 but in the directory /Developer/SDKs there are both 10.5 and 10.4u SDKs.

parisse
Messages : 5882
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Compile Giac on Mac OS X

Message par parisse » sam. déc. 11, 2010 7:00 am

What happens if you replace the SDK4 by SDK5 in mkstat?

pemitsig
Messages : 17
Inscription : lun. nov. 29, 2010 3:26 pm

Re: Compile Giac on Mac OS X

Message par pemitsig » sam. déc. 11, 2010 6:40 pm

Hello,

Changing SDK from 4u to 5 did make a difference. Afterwards though sudo sh mkstat returns some errors about Undefined symbols in the above libraries and files:

lgettextpo
lpng12
ljpeg
libfltk_images.a
Graph3d.o
Cfg.o
Tableur.o
Editeur.o
Equation.o
Graph.o
Help1.o
History.o
Input.o
Xcas1.o

So we remove each and every one of them and ran sudo sh mkstat again untill it returns errors about icas.o as well:

Code : Tout sélectionner

Undefined symbols:
  "xcas::Xcas_load_graph_setup(giac::context const*)", referenced from:
      _main in icas.o
      _main in icas.o
  "xcas::icas_eval(giac::gen&, giac::gen&, int&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, giac::context*)", referenced from:
      _main in icas.o
      _main in icas.o
      _main in icas.o
      _main in icas.o
      _main in icas.o
  "xcas::fltk_view(giac::gen const&, giac::gen&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int, giac::context const*)", referenced from:
      texmacs_graph_output(giac::gen const&, giac::gen&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int, giac::context const*)in icas.o
      _main in icas.o
      _main in icas.o
  "_add_history", referenced from:
      rl_gets(int) in icas.o
  "_using_history", referenced from:
      _main in icas.o
  "_readline", referenced from:
      rl_gets(int) in icas.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
We try to remove icas as well but still no luck.

Any ideas?

Filio and Petros

Répondre