โŒ

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

How do I configure AlgLib for VS2017?

I am compiling a alglib sample program (with a few changes):

#pragma once


# include "Source\RFLearn.h" \\appropriate header for this simple .cpp program.
# include <LinAlg.h>
# include <stdint.h>
# include <chrono> // for in-game frame clock.


int RFLearn::test_function()
{
    alglib::real_2d_array a, b, c;
    int n = 2000;
    int i, j;
    double timeneeded, flops;

    // Initialize arrays
    a.setlength(n, n);
    b.setlength(n, n);
    c.setlength(n, n);
    for (i = 0; i<n; i++)
        for (j = 0; j<n; j++)
        {
            a[i][j] = alglib::randomreal() - 0.5;
            b[i][j] = alglib::randomreal() - 0.5;
            c[i][j] = 0.0;
        }

    // Set global threading settings (applied to all ALGLIB functions);
    // default is to perform serial computations, unless parallel execution
    // is activated. Parallel execution tries to utilize all cores; this
    // behavior can be changed with alglib::setnworkers() call.
    alglib::setglobalthreading(alglib::parallel);

    // Perform matrix-matrix product.
    flops = 2 * pow((double)n, (double)3);
    auto timer_start = std::chrono::high_resolution_clock::now();
    alglib::rmatrixgemm(
        n, n, n,
        1.0,
        a, 0, 0, 0,
        b, 0, 0, 1,
        0.0,
        c, 0, 0);
    auto timer_end = std::chrono::high_resolution_clock::now();
    auto duration = timer_end - timer_start;
    timeneeded = static_cast<double>(duration.count());

    // Evaluate performance
    printf("Performance is %.1f GFLOPS\n", (double)(1.0E-9*flops / timeneeded));

    return 0;
}

I am confident linAlg is correctly linked (as well as all of its dependencies, particularly ap.h and ap.cpp) (Preferences->C++->AllOptions->Additional Include Directories -> aglib's source directory. Changing the link provides a different set of linker errors. AlgLib is a header only-library so I don't think I need to compile any library and add it in the linker.

When compiling this code I get the errors:

1>RFLearn.obj : error LNK2001: unresolved external symbol "public: double * __thiscall alglib::real_2d_array::operator[](int)" (??Areal_2d_array@alglib@@QAEPANH@Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall alglib::real_2d_array::~real_2d_array(void)" (??1real_2d_array@alglib@@UAE@XZ)
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: __thiscall alglib::real_2d_array::real_2d_array(void)" (??0real_2d_array@alglib@@QAE@XZ)
1>RFLearn.obj : error LNK2001: unresolved external symbol "struct alglib::xparams const & const alglib::parallel" (?parallel@alglib@@3ABUxparams@1@B)
1>RFLearn.obj : error LNK2001: unresolved external symbol "void __cdecl alglib::rmatrixgemm(int,int,int,double,class alglib::real_2d_array const &,int,int,int,class alglib::real_2d_array const &,int,int,int,double,class alglib::real_2d_array const &,int,int,struct alglib::xparams)" (?rmatrixgemm@alglib@@YAXHHHNABVreal_2d_array@1@HHH0HHHN0HHUxparams@1@@Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "double __cdecl alglib::randomreal(void)" (?randomreal@alglib@@YANXZ)
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: void __thiscall alglib::ae_matrix_wrapper::setlength(int,int)" (?setlength@ae_matrix_wrapper@alglib@@QAEXHH@Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "void __cdecl alglib::setglobalthreading(struct alglib::xparams)" (?setglobalthreading@alglib@@YAXUxparams@1@@Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "struct alglib::xparams const & const alglib::xdefault" (?xdefault@alglib@@3ABUxparams@1@B)

I intuit that the problem lies around here: http://www.alglib.net/translator/man/manual.cpp.html#gs_configuring

but I cannot make heads or tails of it. What's the next step?

Is there a way to cross-compile with Meson without using a cross-compile file?

I'm trying to cross-compile glib for Android and embed the entire build to a single CMakeLists.txt file inside the Android Studio project.

I have built other dependencies just fine with the "ExternalProject_Add" option in CMake. However, now that I'm trying to do the same for a Meson-based project (glib), I have found out that it requires a separate text file to specify the cross-compilation parameters.

Is there a way to avoid this and specify all the parameters directly in the command itself? Just like with configure or other build systems?

Thanks!

โŒ
โŒ