CoCoA:CoCoA5 Faq

From ApCoCoAWiki
Revision as of 09:22, 16 October 2007 by Dheldt (talk | contribs) (→‎How can I compile and use the library on Windows?: fixing a link.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

CoCoALib Questions

This is the place for all problems as long as it is somehow related to CoCoA 5.

How can I compile and use the library with the Intel C++ on Linux?

After running the configure script provided with the CoCoA Library source you need to edit configuration/ Change



CXXFLAGS_OPT=-O2 -cxxlib-gcc

Obviously the libstdc++.a does not provide any socket functions, but for some reason we have to link the libstdc++ library statically into the CoCoAServer, otherwise the icc linker complains about missing symbols.

Depending on your distribution it might not be possible to use the Intel C++ compiler with the gcc-backend. For example the icc 9.0.32 togther with SuSE 10.0 on x86-64 fails during compilation with

Compiling ZZ.o
/usr/include/c++/4.0.2/cmath(362): error: identifier "__builtin_powil" is undefined
    { return __builtin_powil(__x, __n); }

This is a known problem and Intel has a fix for the upcoming Intel C++ 9.1 release.

From a standpoint of performance the Intel C++ compiler 9.0 is roughly as fast as the gcc 3.X give or take a few percent. The reason lies in the fact that we use the gcc stl backend when using those specific options. Intel provides its own implementation of the stl, but we cannot use it due to some unresolved issues with operators in GOperations.C when usinf the Intel stl backend. If we ever get it to work we will update this documentation.

How can I compile and use the library on Windows?

Please read the CoCoALib:CoCoALib and Cygwin FAQ where you find instructions how to setup the build environment, the needed libraries and the CoCoALib itself in great detail.

How can I a build dynamic version of the CoCoA library on Windows?

If have lots of executables linking to the CoCoA library you can save some space by dynamically linking the CoCoA library instead of using a static version. While most Linux/Unix/MacOSX developers have no preference of static vs. dynamic libraries it is uncommen in the Windows world to deal with static libraries, hence most Windows developers prefer DLLs. While you cannot build the CoCoA library with the Microsoft Visual Studio or Intel compiler just yet (there is work being done for the 0.96 release) one can use MinGW to build a DLL on Windows. This DLL can be used when compiling and linking code with the Visual Studio compiler, i.e. CL.exe.

Ok, here are the instructions to build a DLL on Windows using MinGW:

  1. Apply patch that removes some Unix specific stuff (coming soon - waiting for a clean up)
  2. build library as usual
  3. cd lib: mkdir dll; cd dll
  4. ar x ../libcocoa.a
  5. rm SocketStream.o QuotientModule.o
  6. g++ -shared *.o -o ../cocoa.dll /home/gmp-4.1.4-static/lib/libgmp.a

The resulting DLL with the needed headers can be found here. The DLL is packaged as a self-executing RAR-archive. You still need to get a GMP.DLL.

If you like to use this DLL when compiling example code, i.e. ex-Ring.C you could use something like

g++ -I ../include -I /home/gmp-4.1.4-static/include -L ../lib/ -lcocoa ex-Ring1.C

To use the DLL with the Microsoft Visual Studio compiler one needs to build a .def and a .lib file. This can be done using dlltool from MinGW and lib.exe distributed with Visual Studio. Stay tuned for more details.

How can I compile and use the library on MacOSX

Apple provides a set of development tools which among other things provides a version of the gcc and a development environment called Xcode. Some information about Xcode can be found in this wikipedia article or at the Apple Xcode information page. The version of the gcc shipped with the development tools of MacOSX 10.3 and 10.4 compiles the CoCoALib just fine.

How can I compile and use the library on Solaris

We have build the CoCoA Library on Solaris using the current SunStudio compiler as well as gcc 3.3 and 3.4 in 32 and 64 bit modes.

After running the configure script provided with the CoCoA Library source you need to edit configuration/ Change



CXXFLAGS_OPT=-g -O2 -m64 -mptr64 -Wa,-xarch=v9 -mcpu=v9
SOCKET_LIB= -lnsl -lsocket -lresolv

when using the gcc. For the SunStudio cc use

SOCKET_LIB= -lnsl -lsocket -lresolv

You need to make sure that you have a gmp compiled in the right mode, otherwise the linker will complain about the wrong elf-class when linking the final library. Depending on your installation - usually when compiling in 64 bit mode - one might also need to expand the environment variable LD_LIBRARY_PATH to include the (in case of the gcc) or some other 64 bit version of the libstd (in case of the SunStudio c++ compiler). Otherwise you might run into problems when running binaries that link to the CoCoA libaray since the linker can't find certain libraries.

Debugging the CoCoA Library

If you experience problems with the CoCoA Library there are a couple standard issues which can be quickly eliminated:

  1. Make sure that you gmp was compiled with --no-alloca since large numbers used within the gmp overwrite the stack and make you program crash. More info can be found on the Building_the_gmp page. If you do not know about the compile options used when building the gmp, i.e. you installed a binary build downloaded from somewhere or shipped with your operations system, expanding the stack might make the problem go away. On Linux/Unix/MacOSX this via be done via ulimit. So if expanding the stack makes you crash go away there is a good chance that the cuplrit might b ethe gmp. Attention: While MacOSX 10.3 enables at least the root user to set stacks to unlimited MacOSX 10.4 sets a hard limited of 64kb for stacks. Most modern systems limit the stack size. For Windows we do now know of any way how to set stack size of executables at run-time.

CoCoAServer Questions

The CoCoAServer can be build on Linux, MacOSX or any decent Unix system, i.e *BSD, Solaris, or AIX. On Windows the Cygwin-tools are required; neither MinGW nor the Microsoft compilers can build the CoCoASever due to lack of an implementation of the fork() call. We hope that at some point in the future we will implement a work-around for that issue. Another possibility on Windows is the Microsoft SFU (Services for Unix) package, but since we do not have access we cannot test the build. Microsoft plans to integrate (at least parts of) SFU into Windows Server 2003 R2, so let's see what the future holds.

Know Bugs

For a list of know bugs check out the CoCoALib:KnownIssues. If you have found another bug that is not on that list please consult Reporting_Bugs and if you feel like debugging check out Debugging_CoCoALib if you feel like fixing the problem.