Linking error with LAPACK under cygwin

Similar to the problem described in this question, I want to compile a C++ program using LAPACK under Windows 8.1, using cygwin (and written in NetBeans). I got the necessary packages in cygwin (lapack, liblapack-devel, liblapack0), and have written a function prototype:

extern "C" void dgeev_(char* jobvl, char* jobvr, int* n, double* a, int* lda, double* wr, double* wi, double* vl, int* ldvl, double* vr, int* ldvr, double* work, int* lwork, int* info);

But trying to compile still throws an error from the linker:

$ g++ -llapack -lblas main.cpp /tmp/cc3opfN5.o:main.cpp:(.text+0x349): undefined reference to `dgeev_' /tmp/cc3opfN5.o:main.cpp:(.text+0x403): undefined reference to `dgeev_' collect2: error: ld returned 1 exit status

The code looks like this (adapted from this example):

/* Locals */ int n = N, lda = LDA, ldvl = LDVL, ldvr = LDVR, info, lwork; double wkopt; double* work; double h = k_max / N; /* Local arrays */ double wr[N], wi[N], vl[LDVL * N], vr[LDVR * N]; double a[LDA * N]; /* Initialize matrix */ for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { a[i * N + j] = integral(i + 1, j + 1); if (i == j) { a[i * N + j] += diagonal((i + 1) * h); } } } /* Executable statements */ printf(" DGEEV Example Program Results\n"); /* Query and allocate the optimal workspace */ lwork = -1; char vec[] = "Vectors"; dgeev_(vec, vec, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, &wkopt, &lwork, &info); lwork = (int) wkopt; work = (double*) malloc(lwork * sizeof (double)); /* Solve eigenproblem */ dgeev_(vec, vec, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info);

What am I missing? :-/


Supposing that you have installed BLAS and LAPACK libraries correctly and the system can locate them, then you just have to change the order in the compile command.

$ g++ main.cpp -llapack -lblas

The compiler should know which functions of main.cpp should look into the libraries before declare them.

Category:c# Time:2018-11-03 Views:0
Tags: cygwin lapack

Related post

  • Linker error with libpng under MacOSX 2012-02-19

    I'm working on MacOSX 10.7.2 and Xcode 4.2.1. I installed libpng using port and I was trying to load a PNG image in my application, but I get linker errors: Undefined symbols for architecture x86_64: "_png_create_read_struct", referenced from: loadPn

  • Linker error with Hadoop Pipes 2011-05-18

    Hadoop n00b here, just started playing around with Hadoop Pipes. I'm getting linker errors while compiling a simple WordCount example using hadoop-0.20.203 (current most recent version) that did not appear for the same code in hadoop-0.20.2 Linker er

  • Linker errors with flex and g++? 2011-06-22

    I apologize if this is a straightforward question, but I'm running into some linker errors with flex when I try compiling the resulting scanner with g++. If I give flex the following (very simple) script: %% . ECHO; Then run flex as flex++ scanner.l

  • Linking error with g++ 3.4.4 and g++ 3.4.5 2009-05-11

    Using: windows xp, g++ 3.4.4 with cygwin and g++ 3.4.5 with mingw. I'm compiling a simple unit test class with cppunit. When I link using g++ 3.4.5 I get a lot of linking errors. When I link with g++ 3.4.4 I don't get any errors and the exe links fin

  • Compiling scipy on Windows 32-bit: linker error with libf77blas.a 2010-04-07

    Has anyone tried compiling SciPy 0.7.1 on Windows using numpy-1.3.0 that was built with the pre-built ATLAS libraries ( linked in the installation document. I get the following linker error, and have no ideas as to how to

  • Link Error With Visual Studio 2005 Using Windows SDK 7.1 2010-07-23

    I am in the process of evaluating an upgrade to Windows SDK 7.1 Part of my team's legacy codebase is a large number of ATL web services, which are still maintained using Visual Studio 2005 because (I am told) ATL web services are not supported in ver

  • iPhone how to use CAShapeLayer link error with armv7 2011-10-18

    This probably something really simple, but I have never used CAShapeLayers before, I imported this at the top: import < QuartzCore/QuartzCore.h > And the compiler is not complaining, but the linker is with this error: "_OBJC_CLASS_$_CAShapeLaye

  • linker error with c++ static library which references another library 2011-11-25

    I'm pretty new to c++ and I'm having a problem debugging a linker error. I'm using wxDev-c++ with the g++ compiler. I've created a static library which I'm linking to a basic project. The library originally contained no references to external header

  • Linker error with ostream 2011-12-08

    So I'm back again. I'm not sure if there is a limit to how many questions we can ask in a day so I'm sorry if I'm asking too much but I have a project to do and no more class periods to ask the professor so I'm turning to you guys. Anyway, my problem

  • C++ Linker Error With Class static constexpr 2011-12-09

    I am compiling the following simple program with g++-4.6.1 --std=c++0x: #include <algorithm> struct S { static constexpr int X = 10; }; int main() { return std::min(S::X, 0); }; I get the following linker error: /tmp/ccBj7UBt.o: In function `ma

  • I have link error with OpenCV and XCode4.2 2011-12-10

    I'm trying to link OpenCV in my iPhone project. I upgraded project made on Xcode3.x for latest Xcode. So I need to link opencv built on Xcode 4.3. I followed the guide in But I meet the lin

  • Linker errors with private members of class in header file 2009-03-01

    I'm trying to build a project in Visual Studio 2008. I'm getting a bunch of linker errors that are really bothering me. My application is a Win32 console application using only native ANSI C++. They are all linker errors of the same pattern. Linker e

  • Linker errors with glut.h 2009-03-24

    [Linker error] undefined reference to `[email protected]' [Linker error] undefined reference to `[email protected]' [Linker error] undefined reference to `[email protected]' [Linker error] undefined reference to `glutSolidSphe

  • Link error with Cocotron 2009-03-24

    I've recently built a linux platform interface for Cocotron, and was able to build the Foundation framework with no errors. However, when linking my objective-C project, I get a linker error: /Developer/Cocotron/1.0/Linux/i386/Frameworks/Foundation.f

  • pthread_cond_timedwait linking error with clock_gettime on Solaris 10 2009-07-08

    I have a bit of code which used pthread_cond_wait which looks like this: struct timespec ts; clock_getttime(CLOCK_REALTIME, &timS); ts.tv_sec += delay; pthread_mutex_lock(&a_mutex); pthread_cond_timedwait(&thread_cond, &a_mutex,&t

  • linker errors with openssl on VS 2008 2010-01-23

    I installed the openssl 0.9.8l and added the include and library paths to the VS directories. (I have done this before when installing boost libraries). But i continue to get linker errors. Anyway i can resolve the same. errors are as follows Error 1

  • Linker error with RegSetKeyValue 2010-04-22

    I am using "RegSetKeyValue" API in my application. I am referring to As told in the article, I have defined _WIN32_WINNT_ as 0x0600 and have included Advapi32.lib in my linker options. But

  • Linker error with Duplicated Symbols, SWIG and C++ Vectors 2010-05-21

    I came across this error trying to compile a shared object from 2 sets of objects. The first set contains one .os object compiled from one cpp file generated by SWIG. The second set is contains all of the .so files from the individual files that make

  • iPhone SDK linking errors with static library 2010-05-28

    I've built my own static library with components to be reused in my project, and recently had the need to update a bunch of classes. Specifically, some methods' signatures were changed due to the fact that some classes changed names. What happens now

Copyright (C), All Rights Reserved.

processed in 3.419 (s). 14 q(s)