简体   繁体   English

ansi C程序中的直方图功能:GSL和/或其他?

[英]histogram function in ansi C program: GSL and/or others?

If I just want to use the gsl_histogram.h library from Gnu Scientific Library (GSL), can I copy it from an existing machine (Mac OS Snow Leopard) that has GSL installed to a different machine (Linux CentOS 5.7) that doesn't have GSL installed, and just use an #include <gls_histogram.h> statement in my c program? 如果我只想使用Gnu Scientific Library(GSL)中的gsl_histogram.h库,我可以将它从安装了GSL的现有机器(Mac OS Snow Leopard)复制到不同的机器(Linux CentOS 5.7)吗?安装了GSL,只在我的c程序中使用#include <gls_histogram.h>语句? Would this work? 这会有用吗?

Or, do I have to go through the full install of GSL on the Linux box, even though I only need this one library? 或者,我是否必须在Linux机器上完成GSL的全部安装,即使我只需要这个库?

Just copying a header gsl_histogram.h is not enough. 仅复制标题gsl_histogram.h是不够的。 Header states merely the interface that is exposed by this library. 标头仅表示此库公开的接口。 You would need to copy also binaries like *.so and *.a files, but it's hard to tell which ones to copy. 您还需要复制像*.so*.a文件这样的二进制文件,但很难分辨哪些文件要复制。 So I think the you'd better just install it on your machine. 所以我认为你最好将它安装在你的机器上。 It's pretty easy, just use this tutorial to find and install GSL package. 这很简单,只需使用本教程来查找和安装GSL包。

So there are surely a lot of libraries out there. 所以肯定有很多图书馆。 However the particular one is Gnuplot. 然而,特别的是Gnuplot。 Using it you even do not need to compile the code, however you do need to read a bit of documentation. 使用它你甚至不需要编译代码,但是你需要阅读一些文档。 But luckily there is already a question about how to draw a histogram with Gnuplot on Stackoverflow: Histogram using gnuplot? 但幸运的是,关于如何在Stackoverflow上使用 Gnuplot绘制直方图已经存在一个问题: 使用gnuplot进行直方图? It worth noting that Gnuplot is actually very powerful tool, so invested time into reading its documentation will certainly pay off. 值得注意的是,Gnuplot实际上是非常强大的工具,因此投入阅读其文档的时间肯定会得到回报。

You cannot copy libraries from OS and expect them to work unchanged. 您无法从操作系统中复制库并期望它们保持不变。

OS X uses the Mach-O object file format while modern Linux systems use the ELF object file format. OS X使用Mach-O目标文件格式,而现代Linux系统使用ELF目标文件格式。 The usual ld.so(8) linker/loader will not know how to load the Mach-O format object files for your executable to execute. 通常的ld.so(8)链接器/加载器将不知道如何加载Mach-O格式的目标文件以便执行可执行文件。 So you would need the Apple-provided ld.so(8) -- or whatever they call their loader. 所以你需要Apple提供的ld.so(8) - 或者他们称之为装载机的任何东西。 (It's been a while.) (有一阵子了。)

Furthermore, the object files from OS X will be linked against the Apple-supplied libc , and require the corresponding symbols from the Apple-supplied library. 此外,OS X中的目标文件将链接到Apple提供的libc ,并需要Apple提供的库中的相应符号。 You would also need to provide the Apple-provided libc on the Linux system. 您还需要在Linux系统上提供Apple提供的libc This C library would try to make system calls using the OS X system call numbers and calling conventions. 此C库将尝试使用OS X系统调用号调用约定进行系统调用。 I guarantee the system call numbers have changed and almost certainly calling conventions are different. 我保证系统调用号码已经改变,几乎可以肯定调用约定是不同的。

While the Linux kernel's binfmt_misc generic object loader can be used to teach the kernel how to load different object file formats, and the kernel's personality(2) system call can be used to select between different calling conventions, system call numbers, and so on, the amount of work required to make this work is nothing short of immense: the WINE Project has been working on exactly this issue (but with the Windows format COFF and supporting libraries) since 1993. 虽然Linux内核的binfmt_misc通用对象加载器可用于教内核如何加载不同的目标文件格式,而内核的personality(2)系统调用可用于在不同的调用约定,系统调用号等之间进行选择,完成这项工作所需的工作量是巨大的:自1993年以来, WINE项目一直致力于解决这个问题(但使用Windows格式的COFF和支持库)。

It would be easier to run: 它会更容易运行:

apt-get install libgs0-dev

or whatever the equivalent is on your distribution of choice. 或者等同于您选择的分配。 If your distribution does not make it easily available, it would still be easier to compile and install the library by hand rather than try to make the OS X version work. 如果您的发行版不易于使用,那么手动编译和安装库仍然会更容易,而不是尝试使OS X版本工作。

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

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