Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 02 Dec 1998 18:16:15 -0500
From:      Tod Luginbuhl <tod@science-guy.npt.nuwc.navy.mil>
To:        questions@FreeBSD.ORG
Subject:   Calling LAPACK library from C in 3.0-RELEASE
Message-ID:  <3665CA3F.259C3CB@science-guy.npt.nuwc.navy.mil>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------8B5D41F2AA025F36B7C1DB63
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

I have one machine running 2.2.7-STABLE (last installworld on 25 Sept),
and on this maching, I have no problem calling the LAPACK library from C
(LAPACK etc built using ports).  I recently built a two processor system
using the ASUS P2B-DS mother board which runs 3.0-RELEASE from the
Walnut Creek CDs.  When I try to compile a program that works in STABLE
under 3.0-RELEASE, I get the following error message:

cc -g -L/usr/local/lib -o stupid stupid.o -lm -lblas -llapack -lf2c
/usr/lib/libf2c.so: undefined reference to `MAIN__'
*** Error code 1

Does anyone have any ideas why this is happening and how I might correct
it?   A source list for simple C program that demonstrates the problem
is given below.   I've also included the makefile.  Please email me
directly because I stopped subscribing to this list (when I finish my
dissertation, I'll subscribe again).  Thanks!


- 
------------------------------------------------------------------------

Tod Luginbuhl                         email:  t.e.luginbuhl@ieee.org
Code 2121                                    
luginbuhl@npt.nuwc.navy.mil
Naval Undersea Warfare Center
1176 Howell Street                    Telephone: (401) 832-8241
Newport, Rhode Island                 FAX:       (401) 832-7453
02841-1708
USA

"Don't argue with drunks and fanatics!" -- Sun Wolf (Barbara Hambly)

------------------------------------------------------------------------
--------------8B5D41F2AA025F36B7C1DB63
Content-Type: text/plain; charset=us-ascii; name="stupid.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="stupid.c"

#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <math.h>
#include <limits.h>

#define N 3
#define NSQR N*N

void main(int argc, char **argv)
{
  int i, j, n, info;
  int pivot[N];
  double matrix[NSQR];
  double inverse[NSQR];

  void dgesv(int *, int *,double *,int *,int *,double *,int *,int *);

  for (i=0;i<NSQR;i++) {
      matrix[i] = ((double) random())/((double) INT_MAX);
      inverse[i] = 0.0;
  }
  
  printf("\nMatrix equals...\n\n");
  for (i=0;i<N;i++) {
    inverse[i*N+i] = 1.0;
    for (j=0;j<N;j++) {
      printf("%e ",matrix[i+N*j]);
    }
    printf("\n");
  }

  n = N;
  dgesv_(&n,&n,matrix,&n,pivot,inverse,&n,&info);
  if (0 == info) {
    printf("\n\nMatrix Inverse equals...\n\n");
    for (i=0;i<N;i++) {
      for (j=0;j<N;j++) {
	printf("%e ",inverse[i+N*j]);
      }
      printf("\n");
    }
  }
  else {
    printf("\nI couldn't invert the matrix!!(:-(\n");
  }
  printf("\n");
}

--------------8B5D41F2AA025F36B7C1DB63
Content-Type: text/plain; charset=us-ascii; name="stupid_makefile"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="stupid_makefile"

stupid.o : stupid.c
	cc -c -g stupid.c

stupid : stupid.o
	cc -g -L/usr/local/lib -o stupid stupid.o -lm -lblas -llapack -lf2c


--------------8B5D41F2AA025F36B7C1DB63--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3665CA3F.259C3CB>