How to add ARMA_USE_SUPERLU to C++ project

Nov 22, 2018 at 12:44pm
I added successfully Armadillo library to my c++ project in visual studio(I do not have any problem to use for example sparse matrix from Armadillo), but I have a problem regarding to solve spars matrix (spsolve).
Based on the instruction (http://arma.sourceforge.net/docs.html#spsolve), ARMA_USE_SUPERLU must be enabled in config.hpp, I did it. but when I enable ARMA_USE_SUPERLU in config.hpp I get the "unresolved externals" error.
What is the problem? How can I add SuperLU to my project? is there any one can tell me step by step to add SuperLU, please?

I saw lot of instruction to add the SuperLU, but I could not add it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <Armadillo>

using namespace std;
using namespace arma;
int main(int argc, const char **argv) 
{


    sp_mat A = sprandu<sp_mat>(1000, 1000, 0.1);

    vec b = randu<vec>(1000);
    mat B = randu<mat>(1000, 5);
    vec x;
    x = spsolve(A, b);  


    return 0;

}
Last edited on Nov 22, 2018 at 12:48pm
Nov 22, 2018 at 4:28pm
Nov 23, 2018 at 9:29am
thanks for your reply. But I know what the "unresolved externals" error.
As I said my question is that how can I add SuperLU to my project?

Does any one have experience of using SuperLU?
Nov 23, 2018 at 11:44am
http://arma.sourceforge.net/docs.html#example_prog

Notice this line
g++ example.cpp -o example -O2 -larmadillo

From what you describe, certain options only rely on the "header only" components of the library, and you can safely skip the -larmadillo bit of the command line.

But other parts need the library implementation to go with it.

This means you need to do 2 things:
1. Actually build the downloaded Armadillo library to generate said object library.
2. Configure your visual studio project to pick that library up when your project is being linked.
Nov 23, 2018 at 3:37pm
as I understand I should link the SuperLU library to my project in order to use this function in Armadillo. I downloaded the SuperLU from here (http://crd-legacy.lbl.gov/~xiaoye/SuperLU/) and link to my project in visual studio. but there is a problem in line 15 in my code.

I do not know what is the problem?
Last edited on Nov 23, 2018 at 3:38pm
Nov 23, 2018 at 4:02pm
post the error message
post your build command
Nov 23, 2018 at 4:11pm
When I enable the ARMA_USE_SUPERLU in config.hpp, I got the below error:

1>------ Build started: Project: test, Configuration: Debug x64 ------
1> main.cpp
1>\\130.88.112.127\share\Morteza\porenetwork\test\SuperLU-master\lib\libsuperlu_4.3.a : fatal error LNK1136: invalid or corrupt file
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



1
2
3
4
5
6
#if !defined(ARMA_USE_SUPERLU)
#define ARMA_USE_SUPERLU
//// Uncomment the above line if you have SuperLU.
//// SuperLU is used for solving sparse linear systems via spsolve()
//// Caveat: only SuperLU version 5.2 can be used!
#endif 
Last edited on Nov 23, 2018 at 4:15pm
Nov 24, 2018 at 6:24am
> \\130.88.112.127\share\Morteza\porenetwork\test\SuperLU-master\lib\libsuperlu_4.3.a
That looks like a Unix/Linux library file, and you're compiling on Windows.

You need to make a Windows compatible library of SuperLU and link against that instead.
Topic archived. No new replies allowed.