library_library文件夹 - CSDN
  • R语言中library()和require()的区别

    千次阅读 2017-08-06 15:59:20
    While I was sitting in a conference room at UseR! 2014, I started counting the number of times that require() was used in the presentations, and would rant about it after I counted to ten....

    While I was sitting in a conference room at UseR! 2014, I started counting the number of times that require() was used in the presentations, and would rant about it after I counted to ten. With drums rolling, David won this little award (sorry, I did not really mean this to you).

    After I tweeted about it, some useRs seemed to be unhappy and asked me why. Both require() and library() can load (strictly speaking, attach) an R package. Why should not one use require()? The answer is pretty simple. If you take a look at the source code of require (use the source, Luke, as Martin Mächler mentioned in his invited talk), you will see that require() basically means “try to load the package using library() and return a logical value indicating the success or failure”. In other words, library() loads a package, and require() tries to load a package. So when you want to load a package, do you load a package or try to load a package? It should be crystal clear.

    One bad consequence of require() is that if you require('foo') in the beginning of an R script, and use a function bar() in the foo package on line 175, R will throw an error object “bar” not found if foo was not installed. That is too late and sometimes difficult for other people to understand if they use your script but are not familiar with the foopackage – they may ask, what is the bar object, and where is it from? When your code is going to fail, fail loudly, early, and with a relevant error message. require() does not signal an error, and library() does.

    Sometimes you do need require() to use a package conditionally (e.g. the sun is not going to explode without this package), in which case you may use an if statement, e.g.

    if (require('foo')) {
    } else {
      warning('You missed an awesome function')

    That should be what require() was designed for, but it is common to see R code like this as well:

    if (!require('foo')) {
      stop('The package foo was not installed')


    • library('foo') stops when foo was not installed
    • require() is basically try(library())

    Then if (!require('foo')) stop() is basically “if you failed to try to load this package, please fail”. I do not quite understand why it is worth the circle, except when one wants a different error message with the one from library(), otherwise one can simply load and fail.

    There is one legitimate reason to use require(), though, and that is, “require is a verb and library is a noun!” I completely agree. require should have been a very nice name to choose for the purpose of loading a package, but unfortunately… you know.

    If you take a look at the StackOverflow question on this, you will see a comment on “package vs library” was up-voted a lot of times. It used to make a lot of sense to me, but now I do not care as much as I did. There have been useRs (including me up to a certain point) desperately explaining the difference between the two terms package and library, but somehow I think R’s definition of a library is indeed unusual, and the function library()makes the situation worse. Now I’m totally fine if anyone calls my packages “libraries”, because I know what you mean.

    Karthik Ram suggested this GIF to express “Ah a new library, but requireNoooooo“:

    Since you have read the source code, Luke, you may have found that you can abuse require() a bit, for example:

    > (require(c('MASS', 'nnet')))
    c("Loading required package: c", "Loading required package: MASS",
      "Loading required package: nnet")
    Failed with error:  ‘'package' must be of length 1’
    In addition: Warning message:
    In if (!loaded) { :
      the condition has length > 1 and only the first element will be used
    [1] FALSE
    > (require(c('MASS', 'nnet'), character.only = TRUE))
    c("Loading required package: MASS", "Loading required package: nnet")
    Failed with error:  ‘'package' must be of length 1’
    In addition: Warning message:
    In if (!loaded) { :
      the condition has length > 1 and only the first element will be used
    [1] FALSE
    > library(c('MASS', 'nnet'), character.only = TRUE)
    Error in library(c("MASS", "nnet"), character.only = TRUE) : 
      'package' must be of length 1

    So require() failed not because MASS and nnet did not exist, but because of a different error. As long as there is an error (no matter what it is), require() returns FALSE.

    One thing off-topic while I’m talking about these two functions: the argument character.only = FALSE for library() and require() is a design mistake in my eyes. It seems the original author(s) wanted to be lazy to avoid typing the quotes around the package name, so library(foo) works like library("foo"). Once you show people they can be lazy, you can never pull them back. Apparently, the editors of JSS (Journal of Statistical Software) have been trying to promote the form library("foo")and discourage library(foo), but I do not think it makes much sense now or it will change anything. If it were in the 90’s, I’d wholeheartedly support it. It is simply way too late now. Yes, two extra quotation marks will kill many kittens on this planet. If you are familiar with *nix commands, this idea is not new – just think about tar -z -x -ftar -zxf, and tar zxf.

    One last mildly annoying issue with require() is that it is noisy by default, because of the default quietly = FALSE, e.g.

    > require('nnet')
    Loading required package: nnet
    > require('MASS', quietly = TRUE)

    So when I tell you to load a package, you tell me you are loading a package, as if you had heard me. Oh thank you!



  • 什么是库(library)

    千次阅读 2010-06-24 14:30:00
    什么叫程序库 所谓程序库,一般是软件作者为了发布方便、替换方便或二次开发目的,而发布的一组可以单独与应用程序进行compile time或runtime链接的二进制可重定位目标码文件。通俗一点说,所谓一个库,就是一...


    所谓程序库,一般是软件作者为了发布方便、替换方便或二次开发目的,而发布的一组可以单独与应用程序进行compile time或runtime链接的二进制可重定位目标码文件。通俗一点说,所谓一个库,就是一个文件,这个文件可以在编译时由编译器直接链接到可执行程序中,也可以在运行时由操作系统的runtime enviroment根据需要动态加载到内存中。一组库,就形成了一个发布包,当然,具体发布多少个库,完全由库提供商自己决定。


    所谓静态库,就是在静态编译时由编译器到指定目录寻找并且进行链接,一旦链接完成,最终的可执行程序中就包含了该库文件中的所有有用信息,包括代码段、数据段等。所谓动态库,就是在应用程序运行时,由操作系统根据应用程序的请求,动态到指定目录下寻找并装载入内存中,同时需要进行地址重定向。 win32平台下,静态库通常后缀为.lib,动态库为.dll linux平台下,静态库通常后缀为.a,动态库为.so 从本质上来说,由同一段程序编译出来的静态库和动态库,在功能上是没有区别的。不同之处仅仅在于其名字上,也就是“静态”和“动态”。由上面的介绍不难看出,相对于动态库,静态库的优点在于直接被链接进可执行程序中,之后,该可执行程序就不再依赖于运行环境的设置了(当然仍然会依赖于 CPU指令集和操作系统支持的可执行文件格式等硬性限制)。而动态库的优点在于,用户甚至可以在程序运行时随时替换该动态库,这就构成了动态插件系统的基础。具体使用静态库和动态库,由程序员根据需要自己决定。


    另外,需要说明的一点是,从底层实现上,动态库的效率可能会比静态库稍差一点点,注意,这里用了“可能”二字,具体差不差,还得看写程序的人。之所以可能会差,主要原因在于,程序总无法直接调用动态库中的函数符号,而只能通过调用操作系统的runtime enviroment接口来动态载入某个函数符号,同时获得该函数符号在内存中的地址,将其保存为函数指针进行调用,这就在函数调用时增加了一次间接寻址的过程。

    还是那句话,希望大家都能深入opencv源码库中去,不要仅仅满足于会调几个API,这样很难对自己有提高的。深入进去读源码,看看人家是怎么组织软件架构的,怎么划分模块的。实际上,如果任何一个软件体系的层次模块划分足够清晰和灵活的话,移植性就不会成为很大的问题,无非就是字节对齐、部分算法利用特殊指令集进行优化之类的,这些改动应该仅限于局部调整,而不用全盘重写的。软件架构,很重要的一条就是open-close 原则,要清楚哪些是可变的哪些是不可变的。就像上面,将来会发生变化的算法,就可以考虑放到动态库中,以免将来程序统一全部升级。


    1. 函数、变量名称不变
    2. 函数、变量语法属性不变(比如一个声明为C形式的函数,必须以C形式对其进行调用,否则由于重载特性会找不到函数名)
    3. 函数返回值类型不变
    4. 函数参数个数不变
    5. 函数参数类型不变




  • Library

    2014-12-03 23:42:39
    将一个应用打包为Library 设置工程A,右键->Properties->Android,将Is library项选中,然后Apply。 另外一个应用实现 设置工程B,右键->Properties->Android,在Library中,点击Add按 钮,将A工程加入,...


    设置工程A,右键->Properties->Android,将Is library项选中,然后Apply。


    设置工程B,右键->Properties->Android,在Library中,点击Add按 钮,将A工程加入,然后Apply。此时在B中就引入了A中的资源和代码,这些资源和代码都可以直接调用。需要注意的是,因为A已经不再是一个完整的 Android应用,而是一个类库工程,所以有一些内容还需要在B中配置一下。比如A中有lib库引用,则B中也要加入该lib库;比如A中的 AndroidManifest.xml文件的内容,在B的AndroidManifest.xml文件中也要相应加上。。。


  • 下表显示根据要使用的运行时库应忽略的库。 若要使用此运行时库 请忽略这些库  单线程 (libc.lib) libcmt.lib、msvcrt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib  多线程 (libcmt.lib) libc.lib、msvcrt.lib、lib...


    若要使用此运行时库 请忽略这些库 
    单线程 (libc.lib) libcmt.lib、msvcrt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib 
    多线程 (libcmt.lib) libc.lib、msvcrt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib 
    使用 DLL 的多线程 (msvcrt.lib) libc.lib、libcmt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib 
    调试单线程 (libcd.lib) libc.lib、libcmt.lib、msvcrt.lib、libcmtd.lib、msvcrtd.lib 
    调试多线程 (libcmtd.lib) libc.lib、libcmt.lib、msvcrt.lib、libcd.lib、msvcrtd.lib 
    使用 DLL 的调试多线程 (msvcrtd.lib) libc.lib、libcmt.lib、msvcrt.lib、libcd.lib、libcmtd.lib 


    /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib 
    /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib




    msvcrtd.lib 与 libcmtd.lib 产生冲突




    1.右击工程 - 属性 ”配置属性 - 链接器 - 输入 - 忽略特定库“,添加 ”libcmtd.lib“


    2.右击工程 - 属性 ”配置属性 - 链接器 - 命令行” 添加:  /NODEFAULTLIB:"libcmtd.lib"

  • 自己写简单的Library

    2018-08-20 13:52:16
    在实际的工作中,肯定会发现有些功能RF自身的Library,或者第三方的Library都无法实现,这个时候我们就得自己写library来实现它了。 不要想的太复杂,太难,其实很简单。 下面我们举例子来演示吧一.编写Library 你有...
  • library

    2020-07-29 14:19:51
    NULL 博文链接:
  • library.rar

    2020-05-23 23:31:08
  • RU FORUM SitemapError report DOWNLOAD - 2M (main) - 2M (catalog only) (,, - 2M ...P2P...
  • java一般使用两个path:classpath 和 java.library.path classpath是指向jar包的位置 java.library.path是非java类包的位置如(dll,so) 解决办法: 1:LINUX下的系统变量LD_LIBRARY_PATH来添加java.library...
  • Iintellij Idea中项目引入library的方法

    万次阅读 2015-02-27 17:02:06
  • "library not found for - "解决办法

    万次阅读 多人点赞 2013-08-13 16:43:23
    library not found for -
  • 使用易语言IDE编译的EXE运行时出现"Not found the kernel library or the kernel library is invalid"错误。可以尝试一下几个步骤: 1. 工具-》支持库配置-》全选-》确定 2. 修改注册表“HKEY_USERS\S-1-5-21-...
  • cuDNN 下载地址

    万次阅读 2017-12-06 17:57:34
    cuDNN Archive ...NVIDIA cuDNN is a GPU-accelerated library of primitives for deep neural networks. Download cuDNN v5.1 (August 10, 2016), for CUDA 8.0 Download cuDNN v5.1 (Aug
  • Add Library...添加库,是指一些已经定义好的jar的集合,因为它们经常是一起用   使用场景:下载了jar包后,一些常用的jar的集合(如框架所带的jar),通过添加Library的方法,整个导入以一个整体的形式,方便多...
  • java no XXX in java.library.path错误解决

    万次阅读 2018-03-12 17:37:25
    1,java.lang.UnsatisfiedLinkError: no WrapjGeo in java.library.path2,Java有两个Path,一个是classpath,另外一个library.path。classpath是设置JDK的lib位置.而library.path是设置引用的非Java类包(如DLL,SO...
  • cmake FIND_LIBRARY

    万次阅读 2014-12-06 12:02:45
    LINK_LIBRARY似乎是一个需要避免的命令, 取而代之的是FIND_LIBRARY, 其基本用法是 #在指定目录下搜索一个库, 保存在变量MY_LIB中 FIND_LIBRARY(MY_LIB libmylib.a ./) #链接这个库 TARGET_LINK_...
  • Mac之进入Library目录

    万次阅读 2017-10-22 18:49:50
    Mac 上的~/Library 文件夹是默认为隐藏的。因为苹果觉得在大多数时候,你用不到这个文件夹。但有时候你也许会需要用这个文件夹来完成某些特殊的事情。像小编有时候就会用这个 文件夹来查看我安装在 Mac 上的应用程序...
  • 在较高版本的 Mac OS X 中,用户的资源库文件夹(/Users/username/Library)默认被系统隐藏了,从 Finder 窗口中不能直接打开。解决:  首先切换到 Finder 程序,打开“前往”菜单。    这个时候按住option键位...
  • 在Linux上安装ErLang环境时,如果出现 configure: error: No curses library functions found 提示 ,需要首先安装 ncurses-devel
  • 1 从  或<br />   ... 2 解压 安装:  tar zxvf nginx-0.6.38.tar.gz  cd nginx-0.6.38 ... ./co
1 2 3 4 5 ... 20
收藏数 937,815
精华内容 375,126