简体   繁体   English

如何为 VS2017 配置 AlgLib?

[英]How do I configure AlgLib for VS2017?

I am compiling a alglib sample program (with a few changes):我正在编译一个 alglib 示例程序(有一些更改):

#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.我相信 linAlg 已正确链接(以及它的所有依赖项,尤其是 ap.h 和 ap.cpp)(Preferences->C++->AllOptions->Additional Include Directories -> aglib's source directory。更改链接提供了不同的一组 linker 错误。AlgLib 是 header 唯一库,所以我认为我不需要编译任何库并将其添加到 Z3175B426046787EECE7377387340B982

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我直觉问题出在此处: 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?下一步是什么?

I had a similar (not exact) problem and it went away just by adding the compiled the cpp files to my project and set "included in the project" to true.我有一个类似(不确切)的问题,只需将编译的 cpp 文件添加到我的项目并将“包含在项目中”设置为 true,它就消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM