Compiling PGI PGCC with LAPACK and BLAS libraries

Hi! I’m trying to compile my OpenACC parallel C++ program that makes use of dgemm (BLAS) and dgesvd (LAPACK) functions.

I’m trying to compile the program with PGI PGCC compiler, linking it with the libraries like this (the program is called “VD”):

# Target rules

LIBRARIES := -lblas -llapack -lm

CC = gcc

CFLAGS = -O3

PGCC = pgcc -Minfo=accel -fast -acc -ta=multicore -tp=nehalem -DDEBUG

################################################################################

# Target rules

all: build
build: vd

VD.o: VD.cpp
	$(PGCC) -o $@ -c $< -w

vd: VD.o
	$(PGCC) $(CFLAGS) -o $@ $+ $(LIBRARIES)

clean:
	rm -f VD.o vd

But I get the following error: https://i.stack.imgur.com/giIlr.jpg

It looks like the file is compiling (by this I mean that there are no errors in the code), but when its going to link it to LAPACK (BLAS works) it just doesn’t seem to find some references.

My $(LD_LIBRARY_PATH) variable contains the exact path of LAPACK: /opt/nvidia/hpc_sdk/Linux_x86_64/21.9/compilers/lib/

Here is the first part of my code:

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#include <string.h>

// NUEVOS INCLUDES
#include <openacc.h>
// FIN DE NUEVOS INCLUDES

#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))

#define MAXLINE 200
#define MAXCAD 200
#define FPS 5

extern int dgemm_(char *transa, char *transb, int *m, int *
		n, int *k, double *alpha, double *a, int *lda,
		double *b, int *ldb, double *beta, double *c, int
		*ldc);


extern int dgesvd_(char *jobu, char *jobvt, int *m, int *n,
	double *a, int *lda, double *s, double *u, int *
	ldu, double *vt, int *ldvt, double *work, int *lwork,
	int *info);

Note: I’ve tried to put these latest functions starting with “extern “C” int…” but it doesn’t compile.

What am I missing?

Thank you!

Hi usuario2886,

The BLAS and LAPACK are written in Fortran, hence the error you’re seeing is due to missing the Fortran runtime libraries on the link line.

To fix, add “-fortranlibs” on your link line so these libraries are added.

-Mat

1 Like

That’s it! How quick!! Thank you very much Mat!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.