This is a description of the steps necessary to compile PARI with MSVC6 compiler under WIN32 into a DLL, which can be used through Maple. ======================================================================= I used Pari 2.3.0 (source files) and Maple 10 under WinMe on a Intel PC with 256 MB, but the recipe should work for other configurations. Please note you need two extra file versions for mp.c and pariinl.h which of course are due to Karim Belabas. Acknowledgement: I highly appreciate Karim's help! AVt, Oct 2006 1) You need Maple Before you start: make sure that you have Maple installed together with a valid licence file. The following is for Maple10 (but should work for other versions which support OpenMaple, the C interface). Be sure, that your Maple is installed in a directory *without any blank* in its name. MSVC does not like that and will not find files it seeks. I say this, since a standard installation might place Maple into something like C:\Programme\Maple 10. In this case you are forced to de-install and re-install with proper directory name, I know of no other solution :(- I do not know whether these instruction work for a network installation of Maple (may be problems with licence key files and access). 2) You need MSVC6 Well, that only says, that I have not done that for other MS compilers and I am almost sure that one can even do it with the Watcom C compiler (which is free and is distributed together with Maple), if one would like to do the work of adapting those parts of the distribution. 3) Creating the MSVC project for the DLL Start MSVC, select "File\New..." and pick the "Project" tab to create a new project. Select "Win32 Dynamic Link-Library" as the project type, and specify the project name as "pari_mpl" (we will change the location later). Click "OK", then on the next screen select "A simple DLL project" and click "Finish" and confirm the following information pop-up. If not already having it as your default: through the menu/view activate the workspace now to be seen on the left. Click on the file view tab and open the complete tree for the pari_mpl files there. Close the project. Create a directory C:\temp\pari_maple and move the created project to that place as subdirectory. Change the name C:\temp\pari_maple\pari_mpl\pari_mpl.cpp to have extension "c" only (to have no problems with C++ behaviour). Open the project by double klick on C:\temp\pari_maple\pari_mpl\pari_mpl.dsw and within the workspace mark and delete the file pari_mpl.cpp. Then select "Project\Add to project\Files..." to add files to the project, choose pari_mpl.c by double klick. Activate it in the work space and if you see the following source everything is ok so far: // pari_mpl.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } You can exit the project now and get some coffee. If you never did that, it would be better to do some simple projects first. 3) Extracting the sources Expanding the archive pari-2.3.0.tar.gz is not so common on Windows. I use Easyzip, it will expand it to a tar file, which contains the actual sources (Easyzip is old and free and can handle most Unix stuff, its built in viewer has no problems with Unix line feeds). May be Winzip or 7zip can do that as well. Expand all files together with the directory structure, the base directory is pari-2.3.0 and since MSVC does not like such names rename it, pari_maple is the name I use. 4) Selecting needed source files One can delete every file not having an extension *.h or *.c (for better overview only, sort by extension in Window's explorer and then delete) from the distributed sources for pari 2.3.0. Moreover one can delete any subdirectory such that only the following tree remains: pari_maple | |---- Odos | |---- src | |---- basemath |---- graph |---- headers |---- kernel | |---- none | |---- language |---- modules You do not not need other directories for the project and if you want to create a simple command line exe or a DLL then it is without GP, so one does not need the directory gp (I have not tried to ignore graph). Note: the other possible kernels are not used, no assembler is used. Now prepare which files are actually needed and which can be deleted: - Replace the following files from the original distribution by the accompanied version (written by Karim Belabas): Odos/pariinl.h src/kernel/none/mp.c - From Odos you only need (delete the others) pariinl.h paricfg.h - From basemath you need all of the 33 files - From graph you need (delete the others) plotnull.c plotport.c rect.h - From headers all of the 14 files are needed - From kernel/none you need (delete the others) level1.h mp.c mpinl.c tune-gen.h - From language you need all of the 12 files - From modules you need all of the 13 files Now copy that re-named base (with its subdirectories) to C:\temp\pari_maple, we will work here, our MSVC project is already there. That structure of directories is needed due to the coding conventions used in PARI. 5) Adding PARI sources to the project Re-open the project through pari_mpl.dsw and as shown above add all of the C source and header files prepared in step 4 (one has to stepp through all the directories). 5) Configuring the project Select "Build/Set Active Configuration" and and activate the release version (except you want debug ...) and confirm. Select "Project/Settings" and pick the "C/C++" tab. Within category "Code Generation" take "Multithread DLL" as runtime library. Within category "Optimization" for me works "Any suitable" for the inline functions, but there is no need to change the default (which is "Only __inline". Within category "Precompiled Headers" I never use default and change to "Automatic use ..." May be you want to save your settings now and then ... 6) Adding pathes to the project One has to tell MSVC where to find source files for PARI and Maple. That is done through "Project/Settings" and again the "C/C++" tab, now in the last category "Preprocessor". Into the "Additional include directories" box for PARI files enter C:\temp\pari_maple\Odos,C:\temp\pari_maple\src\headers and append C:\Programme\Maple10\extern\include for Maple (that depends on your Maple installation), do not include in string quotes. Confirm. Moreover MSVC will need a static Maple library and through the tab "Link", category "General" one adds maplec.lib into the "Object/ library" box (just type it in at first place, no comma sign, just a blank space after that). Confirm. 7) Final compilation Save workspace and try to compile. It should do without errors and about 100 warnings (ignore them all). If it is ok so far then add the actual code into the file pari_mpl.c and compile again. Hopefully done: that should work (but your coffee is probably cold now). If it is ok now, then everything except the DLL can be deleted in the release directory. Please note that the resulting DLL does not make use of any assembler routines and is for a general processor type, so it would be slower than the original distributed binaries (may be using gcc would do it better then MSVC). 8) Using the DLL through Maple For using the stuff just try the accompaning Maple worksheet which is simply placed into the release directory, it expects the DLL in its directory (in case of troubles finding the path, please do it by hand or check Maple's help). There are some subtilities related to precision set for Maple. A major thing is: Maple does a lot of overhead including symbolics (that is its main purpose). And works with _relative_ precision, so results will be not directly comparable. The advantage in speed for pure numerics is by a factor 3 - 10 for this DLL and may be some additional 50% better having a version with assembler parts. The Pari page talks of further improvements, if one would switch from its built-in multiprecision to another GNU library, but I do not try this. 9) Some issue One issue calling Pari from Maple is related to the fact, that Pari generates everything it needs with its own memory management. If it is set up and exited in a regular way, then Pari will build what it needs and finally will clean it up through pari_init and pari_close. However if it is called from outside one should take care to execute these commands. If Maple is simply exited or restarted (by a Maple command) this is not guaranteed and by repeated use this may result in a dedicated crash. To avoid that in the example worksheet the construction of a Maple module is used. This should ensure that ModuleLoad, ModuleUnload are executed to call the needed Pari commands (check Maple's help for all the details). It seems to work then, but a sound way is to init and close Pari explicitely. PS: I tried to do similar by connecting to the 'official' libpari.dll, but at least on WinME (~ Win98) that does not work and I have the feeling this is related to cygwin1.dll used in there (by looking in it using the dependency walker). If one calls libpari.dll (with absolute path) by hLib=LoadLibrary then the underlying error is "1157 One of the library files needed to run this application cannot be found. ERROR_DLL_NOT_FOUND ". Copying both libpari.dll and cygwin1.dll to windows/systems gives no error message. But the thing hangs up. So I gave up after some trials for solutions (I can not examine what happens, if both the official DLLs would be complied to live in windows/systems).