简体   繁体   English

如何在Windows上安装C软件包

[英]How do I install C packages on windows

I have to use LU decompostion to fit a simple model to some data (simulated) in C. An example of what I need to do is here : 我必须使用LU分解将简单模型拟合到C中的某些数据(模拟)。在这里我需要做的一个例子:

However, I'm stuck with a more basic problem: how do I install packages in C and call them in my code? 但是,我遇到了一个更基本的问题:如何在C中安装软件包并在代码中调用它们?

I'm new in C and I'm used to R. But I have this assingment to do some tests about Matrix inversion, LU decomposision and the professor suggested using Lapack to easy things (thus, I don't need to code myself the LU decomposition etc.). 我是C语言的新手,并且习惯于R。但是我有这样的要求来做一些关于矩阵求逆,LU分解的测试,而教授建议使用Lapack来简化事情(因此,我不需要自己编写代码LU分解等)。 But I don't know how to install the package and call it in my code, in order to use the functions of LAPACK. 但是我不知道如何安装该软件包并在我的代码中调用它,以便使用LAPACK的功能。

I have a windows 7 64 bits and I'm using compiler Code Blocks 8.02 我有一个Windows 7 64位,正在使用编译器代码块8.02

Thanks for any help. 谢谢你的帮助。

Normally you don't "install" C libraries in that sense. 通常,您不会从这种意义上“安装” C库。 Normally, in Windows you have three types of files. 通常,在Windows中,您具有三种类型的文件。 The header files, typically ending in .h, the dynamic library, .dll, and most likely some linker files (typically, .lib, .a or something). 头文件(通常以.h结尾),动态库,.dll以及最有可能的某些链接程序文件(通常是.lib,.a或其他名称)。 The linker and compiler will need to be able to find these files somewhere. 链接器和编译器将需要能够在某些地方找到这些文件。 Normally you set the include directory paths, and library directory paths. 通常,您设置包括目录路径和库目录路径。

Eg Let's say you downloaded a library called foo, and you extract it to C:\\foo. 例如,假设您下载了一个名为foo的库,然后将其解压缩到C:\\ foo。 In that folder, libfoo.a , foo.dll and foo.h reside. 在该文件夹, libfoo.afoo.dllfoo.h居住。 In Code::Blocks you will have to point include directory path to C:\\foo and library path to C:\\foo so that the linker and compiler know where to look for these files. 在代码::块,你将有指向包括对目录路径C:\\foo和库路径C:\\foo ,以便链接器和编译器知道去哪里找这些文件。 Since you're linking against the foo library, you will also have to set -lfoo or something similiar in linker command line. 由于要针对foo库进行链接,因此还必须在链接器命令行中设置-lfoo或类似内容。 This is GCC syntax, but I think Code::Blocks uses GCC compiler behind the scenes anyways. 这是GCC语法,但是我认为Code :: Blocks仍然在后台使用GCC编译器。

In the C code you can just #include <foo.h> and the compiler will find it for you. 在C代码中,您只需#include <foo.h> ,编译器就会为您找到它。

You need to install that library and it might actually supply a tool for that. 您需要安装该库,它可能实际上为此提供了一个工具 Check their documentation (eg a file INSTALL or README in their distributed sources). 检查他们的文档(例如,在其分布式源中的文件INSTALLREADME )。 If the library uses only headers you might only need to copy it's headers to some directory on your system, but their buildsystem might be able to do that for you. 如果该库仅使用头文件,则可能只需要将其头文件复制到系统上的某个目录中,但是它们的buildsystem可以为您完成此操作。

Once that is done you would tell your IDE on where to look for the sources and if the library uses not just headers to link against the actual library file. 完成此操作后,您将告诉IDE在哪里寻找源代码,以及库是否仅使用标头链接到实际库文件。 See the documentation in the Code::Blocks Wiki on how this is done for some example cases and adapt for your library. 请参阅Code :: Blocks Wiki中的文档, 了解在某些示例情况下如何完成此操作以及如何适应您的库。

The simplest thing to do in your situation is to install Cygwin . 根据您的情况,最简单的操作是安装Cygwin You can use the setup.exe installer to install the GCC and the LAPACK libraries. 您可以使用setup.exe安装程序来安装GCC和LAPACK库。 When you want to use the LAPACK library, you will add the -llapack option to your GCC command line. 当您想使用LAPACK库时,可以将-llapack选项添加到GCC命令行中。

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

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