繁体   English   中英

在 Win10 上使用 CodeBlocks 安装 GSL 库

[英]Installing GSL library with CodeBlocks on Win10

我尝试使用 CodeBlocks IDE 在 Win10 上安装 GSL。
我从http://gnuwin32.sourceforge.net/packages/gsl.htm下载了完整的 package,2006 年 7 月 11 日的来源除外
我用下面的代码尝试一个简单的例子

#include <stdio.h>
#include <stdlib.h>`
#include <gsl/gsl_sf_bessel.h>

int main(int argc, char* argv[])
{
    printf("Hello world!\n");
    double x = 5.0;
    double y = gsl_sf_bessel_J0(x);

    printf ("Besel test J0(%g) = %.18e\n", x, y);
    return 0;
}

我把编译器的搜索目录 D:\Windows\Sofwares\gsl-1.8\include
和 D:\Windows\Sofwares\gsl-1.8\lib\libgsl.a
D:\Windows\Sofwares\gsl-1.8\lib\libgslcblas.a
在 linker 设置中。

当我尝试构建时,我收到错误消息 undefined reference to `gsl_sf_bessel_J0'|

我在下面描述的方法被定义为“动态库的静态链接”(dll)。
步骤 1) Go 到 'Project buid options' -> select 'Search directory' 选项卡 -> GnuWin32\include \'Compiler' 选项卡上单击 -> 'Compiler' 选项卡

在此处输入图像描述

步骤 2) 停留在“搜索目录”选项卡和 select“链接器”-> 单击“添加”按钮并浏览GnuWin32\lib文件夹。

在此处输入图像描述

步骤 3) 单击“链接器设置”选项卡 -> 单击添加按钮并键入使用 GSL 所需的库文件的名称。
库文件必须不带“lib”前缀和“.a”后缀。

在此处输入图像描述

Step 4) Go to the GnuWin32\bin directory -> copy the dll files ( libgsl.dll and libgslcblas.dll ) and paste to the folder containing your CodeBlock project file.

在此处输入图像描述

将两个 dll 文件再次粘贴到bin/Debugbin/Release目录中,您将在其中找到程序的可执行文件。

步骤 5) 编写自己的程序,编译并启动。
现在一切都应该工作

在此处输入图像描述

暂无
暂无

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

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