According to R-admin.pdf, I built the standalone Rmath library on my Mac. The first test program seemed compiled and linked well, but generated an error message. The followings are my procedures:
根据R-admin。我在我的Mac上建立了一个独立的Rmath库。第一个测试程序似乎被编译并链接得很好,但是产生了一个错误消息。以下是我的流程:
$ cc -o test test.c -I /library/frameworks/r.framework/headers
-L/users/ed/downloads/r-2.13.1/src/nmath/standalone/ -lRmath -lm
$ ./test
dyld: Library not loaded: libRmath.dylib
Referenced from: .....
Reason: image not found
Trace/BPT trap
$
Thanks in advance.
提前谢谢。
2 个解决方案
#1
3
I found a way to compile and link C code including Rmath.h. When you choose default installation, the path for the header is /library/frameworks/r.framework/headers, and the path for the library is /library/frameworks/r.framework/libraries.
我找到了一种方法来编译和链接C代码,包括Rmath.h。当您选择默认安装时,头文件的路径是/library/framework /r.framework/header,而库文件的路径是/library/framework /r.framework/libraries。
$ gcc -I/library/frameworks/r.framework/headers -c test.c
$ gcc -L/library/frameworks/r.framework/libraries test.o -lRmath -o progname
Single line implementation is also convenient:
单行实现也很方便:
$ gcc -I/library/frameworks/r.framework/headers test.c \
-L/library/frameworks/r.framework/libraries -lRmath -o progname
I found that Objective-C program can include standalone Rmath.h as well. Implementation is as follows: (name of the objective-c program is 'test.m.')
我发现Objective-C程序可以包含独立的Rmath。h。实现如下:(objective-c程序的名称是'test.m.')
$ gcc -framework Foundation -I/library/frameworks/r.framework/headers test.m
-L/library/frameworks/r.framework/libraries -lRmath -o progname
I added this comment in the hope that it will be useful...
我加了这条评论,希望它有用……
#2
0
I'm not a mac guy, but you need to ensure your program finds libRmath.dylib. On Linux you would set LD_LIBRARY_PATH...
我不喜欢mac,但你需要确保你的程序找到libRmath.dylib。在Linux上,您可以设置LD_LIBRARY_PATH…
#1
3
I found a way to compile and link C code including Rmath.h. When you choose default installation, the path for the header is /library/frameworks/r.framework/headers, and the path for the library is /library/frameworks/r.framework/libraries.
我找到了一种方法来编译和链接C代码,包括Rmath.h。当您选择默认安装时,头文件的路径是/library/framework /r.framework/header,而库文件的路径是/library/framework /r.framework/libraries。
$ gcc -I/library/frameworks/r.framework/headers -c test.c
$ gcc -L/library/frameworks/r.framework/libraries test.o -lRmath -o progname
Single line implementation is also convenient:
单行实现也很方便:
$ gcc -I/library/frameworks/r.framework/headers test.c \
-L/library/frameworks/r.framework/libraries -lRmath -o progname
I found that Objective-C program can include standalone Rmath.h as well. Implementation is as follows: (name of the objective-c program is 'test.m.')
我发现Objective-C程序可以包含独立的Rmath。h。实现如下:(objective-c程序的名称是'test.m.')
$ gcc -framework Foundation -I/library/frameworks/r.framework/headers test.m
-L/library/frameworks/r.framework/libraries -lRmath -o progname
I added this comment in the hope that it will be useful...
我加了这条评论,希望它有用……
#2
0
I'm not a mac guy, but you need to ensure your program finds libRmath.dylib. On Linux you would set LD_LIBRARY_PATH...
我不喜欢mac,但你需要确保你的程序找到libRmath.dylib。在Linux上,您可以设置LD_LIBRARY_PATH…