help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] can not use the GSL.dll with other compilers (lcc or borland)


From: hk wieso
Subject: [Help-gsl] can not use the GSL.dll with other compilers (lcc or borland)
Date: Thu, 20 Nov 2003 21:11:28 +0000

The test-program at the bottom compiles and links, but hangs at the invocation of [gsl_matrix_fwrite]

In the case of Borland and lcc an import library gsl.lib was created from gsl.dll with the relevant compiler tool and linked into the project..

Can someone tell me whether I am just doing something wrong , or whether importing libraries from other compilers is a bad idea and I just should recompile GSL? gsl.dll is an ANSI C library, compiled by visual c++ 7x.

FWIW:
1/ I ran the same test calling another GSL function [gsl_log1p] and it runs fine on both compilers. Is there something specific to [gsl_matrix_fwrite] like file handling or memory allocation that would travel badly across compilers?
2/ I had the same problem with [gsl_matrix_fread].
3/ I will be crossposting to comp.compiler.lcc and share any knowledge I may receive there.

Best regards.
Jean.

lcc page (free compiler):http://www.cs.virginia.edu/~lcc-win32/

Sorry it is a bit long, but you can cut and paste and compile-in lcc. The offending line is the one with [gsl_matrix_fwrite]








/* --- The following code comes from C:\desktop\lcc\lib\wizard\textmode.tpl. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "c:\desktop\include\GSL4\include\gsl\gsl_matrix.h"
void Usage(char *programName)
{
        fprintf(stderr,"%s usage:\n",programName);
        /* Modify here to add your usage message when the program is
         * called without arguments */
}

/* returns the index of the first argument that is not an option; i.e.
  does not start with a dash or a slash
*/
int HandleOptions(int argc,char *argv[])
{
        int i,firstnonoption=0;

        for (i=1; i< argc;i++) {
                if (argv[i][0] == '/' || argv[i][0] == '-') {
                        switch (argv[i][1]) {
                                /* An argument -? means help is requested */
                                case '?':
                                        Usage(argv[0]);
                                        break;
                                case 'h':
                                case 'H':
                                        if (!stricmp(argv[i]+1,"help")) {
                                                Usage(argv[0]);
                                                break;
                                        }
                                        /* If the option -h means anything else
                                         * in your application add code here
                                         * Note: this falls through to the 
default
                                         * to print an "unknow option" message
                                        */
                                /* add your option switches here */
                                default:
                                        fprintf(stderr,"unknown option 
%s\n",argv[i]);
                                        break;
                        }
                }
                else {
                        firstnonoption = i;
                        break;
                }
        }
        return firstnonoption;
}

/*------------------------------------------------------------------------
Procedure:     main ID:1
< 100; j++) Purpose:
Input:
Output:
Errors:
------------------------------------------------------------------------*/
int main(int argc,char *argv[])
{
   int u=0;
        if (argc == 1) {
                /* If no arguments we call the Usage routine and exit */
                Usage(argv[0]);
                return 1;
        }
        /* handle the program options */
        u=HandleOptions(argc,argv);
        /* The code of your application goes here */
          int i, j, k = 0;
      gsl_matrix * m = gsl_matrix_alloc (100, 100);
      gsl_matrix * a = gsl_matrix_alloc (100, 100);

      for (i = 0; i < 100; i++)
        for (j = 0; j < 100; j++)
          gsl_matrix_set (m, i, j, 0.23 + i + j);

      {
         FILE * f = fopen ("test.dat", "wb");
         gsl_matrix_fwrite (f, m);
         fclose (f);
      }

      {
         FILE * f = fopen ("test.dat", "rb");
         gsl_matrix_fread (f, a);
         fclose (f);
      }
      for (i = 0; i < 100; i++)
        for (j = 0; j < 100; j++)
          {
            double mij = gsl_matrix_get (m, i, j);
            double aij = gsl_matrix_get (a, i, j);
            if (mij != aij) k++;
          }

      printf ("differences = %d (should be zero)\n", k);

        return 0;
}

_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous ! http://search.msn.fr/worldwide.asp





reply via email to

[Prev in Thread] Current Thread [Next in Thread]