简体   繁体   English

如何在 c 中调用 ran2() function

[英]How to call ran2() function in c

Are ran1,ran2, ran3 functions are included in the library?库中是否包含 ran1、ran2、ran3 函数? Does these needs some header file or package?这些是否需要一些 header 文件或 package? How to mention in the program and how to call.程序中怎么提,怎么调用。

I just know the basic programmings.I am trying to learn random variable generators.I have looked in the book numerical recipe there are three functions ran1,ran2 and ran3.I want to know how this function called or used in the program?我只知道基本的编程。我正在尝试学习随机变量生成器。我看过数值食谱一书中有三个函数 ran1,ran2 和 ran3。我想知道这个 function 在程序中是如何调用或使用的? How to mention this functions in my program?如何在我的程序中提及此功能?

In order to use a function ( ran1() , ran2() or ran3() ) from a library X you usually have to include the header in your_file.c :为了使用库 X 中的 function( ran1()ran2()ran3() ),您通常必须在 your_file.c 中包含your_file.c

#include <X.h>

Tell the compiler which directory to find said header if it's in a non-standard location.如果 header 位于非标准位置,则告诉编译器找到哪个目录。 Say, the header is path/include/Xh , then you would compile the file with:假设 header 是path/include/Xh ,那么您将使用以下命令编译文件:

gcc -Ipath/include -c your_file.c

And you link the library by using the -L to tell where the dynamic library is located, say, path/lib/libX.so :并且您通过使用 -L 来链接库以告知动态库所在的位置,例如path/lib/libX.so

gcc -Lpath/lib -lX your_file.o -o your_file

If your library ships with a.pc file then you use pkg-config --cflags libX for the compilation, and pkg-config --libs libX for linking.如果您的库附带一个 .pc 文件,那么您可以使用pkg-config --cflags libX进行编译,并使用pkg-config --libs libX进行链接。 Note there is some variability in the naming of the pc file so look at what your library uses if any.请注意,pc 文件的命名存在一些差异,因此请查看您的库使用的内容(如果有)。

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

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