RcppGSL Windows installation trouble - c++

I'm trying to install RcppGSL as presented in
Linking GSL library to RcppGSL on Windows machine
after copping the library as presented in the link above to C:/local323
and moving all the files in x64 up one directory into into LIB_GSL/lib as presented in the link. I used the following code.
library(Rcpp)
Sys.setenv("LIB_GSL" = "C:/local323") # this is where the library is located
Sys.setenv("PKG_LIBS"="-L(LIB_GSL)/lib -lgsl -lgslcblas")
install.packages("RcppGSL")
I added the line
Sys.setenv("PKG_LIBS"="-L(LIB_GSL)/lib -lgsl -lgslcblas")
after getting the following error(and I still got the same error) after doing some research and thought there might be a linking problem(just guessing).
The error I received was
RcppExports.o:RcppExports.cpp:(.text+0x916): undefined reference to `gsl_matrix_alloc'
RcppExports.o:RcppExports.cpp:(.text+0x945): undefined reference to `gsl_matrix_set'
RcppExports.o:RcppExports.cpp:(.text+0x993): undefined reference to `gsl_vector_calloc'
fastLm.o:fastLm.cpp:(.text+0x122): undefined reference to `gsl_vector_calloc'
fastLm.o:fastLm.cpp:(.text+0x131): undefined reference to `gsl_matrix_alloc'
fastLm.o:fastLm.cpp:(.text+0x142): undefined reference to `gsl_multifit_linear_alloc'
fastLm.o:fastLm.cpp:(.text+0x16d): undefined reference to `gsl_multifit_linear'
fastLm.o:fastLm.cpp:(.text+0x175): undefined reference to `gsl_multifit_linear_free'
fastLm.o:fastLm.cpp:(.text+0x24f): undefined reference to `gsl_matrix_diagonal'
setErrorHandler.o:setErrorHandler.cpp:(.text+0x104): undefined reference to `gsl_set_error_handler_off'
setErrorHandler.o:setErrorHandler.cpp:(.text+0x133): undefined reference to `gsl_set_error_handler'
any help is greatly appreciated!
Very best,
Steve

I would try this on the command-line, ie in cmd.exe -- not from R.
That way you should see the compilation and linking steps which may help when something go south.
"It builds at CRAN ..." so with the right files in the right location, and the proper env var set it should for you too.

Well I do not know why the following worked but I'm able to use RcppGSL
I followed the procedure from the link I posted exactly. Then instead of using
install.packages("RcppGSL")
I downloaded the zip file from CRAN and installed the package via the R GUI with the option to install from a zip. These should be identical I know, but using install.packages("RcppGSL").
Also
Sys.setenv("LIB_GSL" = "C:/local323")
is required anytime I try to compile an Rcpp file that uses the library.
I'm not sure why, but I can use the library at least.
Dirk thank you for your help. I will go over the tutorial on R-extensions to see if I can figure out what is going on.

Related

Build errors in C++ project with OpenCV in Eclipse: undefined reference to `SelectObject#8' + many others

I'll start by saying that I don't have much experience at all with compiled languages, this may be obvious but I've done a few solid hours searching and have come up empty-handed.
I am trying to build this project in Eclipse. I have built and imported OpenCV 3.1, and everything seems okay until I go to build the project. At that point I get a wide array of error messages saying that I have 'undefined references'.
For example:
C:\dev\opencv\build\x64\mingw_s\lib/libopencv_highgui310.a(window_w32.cpp.obj):window_w32.cpp:(.text$_ZL15icvRemoveWindowP8CvWindow+0x11b): undefined reference to `SelectObject#8'
C:\dev\opencv\build\x64\mingw_s\lib/libopencv_highgui310.a(window_w32.cpp.obj):window_w32.cpp:(.text$_ZL15icvRemoveWindowP8CvWindow+0x126): undefined reference to `DeleteObject#4'
C:\dev\opencv\build\x64\mingw_s\lib/libopencv_highgui310.a(window_w32.cpp.obj):window_w32.cpp:(.text$_ZL15icvRemoveWindowP8CvWindow+0x138): undefined reference to `DeleteDC#4'
C:\dev\opencv\build\x64\mingw_s\lib/libopencv_highgui310.a(window_w32.cpp.obj):window_w32.cpp:(.text$_ZL16icvGetBitmapDataP8CvWindowP7tagSIZEPiPPv.isra.0+0x1e): undefined reference to `GdiFlush#0'
C:\dev\opencv\build\x64\mingw_s\lib/libopencv_highgui310.a(window_w32.cpp.obj):window_w32.cpp:(.text$_ZL16icvGetBitmapDataP8CvWindowP7tagSIZEPiPPv.isra.0+0x32): undefined reference to `GetCurrentObject#8'
C:\dev\opencv\build\x64\mingw_s\lib/libopencv_highgui310.a(window_w32.cpp.obj):window_w32.cpp:(.text$_ZL16icvGetBitmapDataP8CvWindowP7tagSIZEPiPPv.isra.0+0x6d): undefined reference to `GetObjectA#12'
Full console output is here.
From what I've seen, the causes of this error in general can be varied, perhaps the specifics of my case would allow a more precise answer.
I get the feeling that I'm not importing something correctly, or not setting an appropriate flag, but I have no idea what it is, or how to accomplish it. Any help would be greatly appreciated.
Matt
All your missing functions are in Gdi32.lib Search "msdn SelectObject" (for example) - scroll down to requirements add missing libraries to project
-- comment by Richard Critten

How to Install/Use libcurl with C++ on Windows/Eclipse CDT

Can someone please explain how to use libcurl with C++ on Windows with Eclipse CDT/Code::Blocks or a similar IDE?
I'm very new to C++ but I know my way around Java very well.
I'm using MinGW but I keep getting this error:
C:\Core\src>g++ -I"C:\curl\include\curl" -L"C:\curl\lib64" -lcurldll core.cpp -o
core.exe
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xc81): undefined
reference to `_imp__curl_easy_init'
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xca7): undefined
reference to `_imp__curl_easy_setopt'
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xcc4): undefined
reference to `_imp__curl_easy_setopt'
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xcd1): undefined
reference to `_imp__curl_easy_perform'
C:\Users\Bob\AppData\Local\Temp\cc2BV0HI.o:core.cpp:(.text+0xce1): undefined
reference to `_imp__curl_easy_cleanup
What I've Tried:
If I give the wrong library path/name it will tell me that it can not find the library. So clearly it FOUND the libcurldll.a/libcurl.a files but it isn't linking with them properly.
I've tried putting the actual libcurl.dll file from the bin into every source folder possible in my project.
I've tried going to C/C++ General > Paths and Symbols then added "curl" and "curldll" to libraries and "C:\curl\lib64" to the library search path.
I've tried manually adding the -lcurl, -lcurldll, -DCURL_STATICLIB, -L"C:\curl\lib64" options to the MinGW Linker tool.
This has been stumping me for days. Please help.

How to link mysql in dev c++?

I just downloaded http://dev.mysql.com/downloads/mirror.php?id=414392 and set include/bin/lib folders to my compiler(tdm-gcc 4.8.1) in dev c++.
I can use functions from mysql.h (#include )
But i cant compile program.
bcoz:
undefined reference to `mysql_init'
undefined reference to `mysql_select_db'
what i have to do?
You've got the '-L' arguments including the lib directories, but you don't appear to have a '-l' argument linking the actual library. I think what you want to add is '-lmysqlclient' or something similar. Please see the following page for more information:
http://dev.mysql.com/doc/refman/5.0/en/c-api-building-clients.html

Linking Intel's MKL (BLAS & LAPACK) to GCC

I am trying to compile a giant software package, and this is the last hurdle I can't seem to figure out.
I'm getting errors like:
RNDiracDeterminantBase.cpp:(.text+0x22bf): undefined reference to `dgetrf_'
RNDiracDeterminantBase.cpp:(.text+0x2524): undefined reference to `dgetri_'
RNDiracDeterminantBase.cpp:(.text+0x3005): undefined reference to `dgetri_'
../../lib/libqmcwfs.a(RNDiracDeterminantBase.cpp.o): In function `qmcplusplus::RNDiracDeterminantBase::ratio(qmcplusplus::ParticleSet&, int, qmcplusplus::ParticleAttrib<qmcplusplus::TinyVector<double, 3u> >&, qmcplusplus::ParticleAttrib<double>&)':
RNDiracDeterminantBase.cpp:(.text+0x4156): undefined reference to `dgemv_'
RNDiracDeterminantBase.cpp:(.text+0x420f): undefined reference to `dger_'
Google reveals that these references are to Intel's MKL library. However, I don't know what file I need to link. I've tried libmkl_core.a, libmkl_gnu_thread.a, libmkl_blacs_intelmpi_lp64.a, etc. There's tons of files in:
/mkl/lib/intel64/
Can post more information if requested.
I don't know what file I need to link. I've tried libmkl_core.a, libmkl_gnu_thread.a, libmkl_blacs_intelmpi_lp64.a, etc. There's tons of files in: /mkl/lib/intel64/
The fact that there are tons of files doesn't mean you have to try each library in turn.
To find out which library defines the symbols you want, run this command:
cd /mkl/lib/intel64
nm -A *.a | egrep '[TWBD] (dger_|dgemv_|dgetrf_|dgetri_)$'
Also be sure to put libraries at the end of your link line, as the order of archive libraries on command line matters.
Based on the incomplete information you provided, it's likely that you need libmkl_intel_lp64.a, libmkl_gnu_thread.a, and libmkl_core.a.
Intel MKL has a built-in tool to help you figure out linking: /mkl/tools/mkl_link_tool. This tool is also available on the web: http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor. Use this tool to get the exact link line for your situation.
You should have asked your question on the official MKL forum (http://software.intel.com/en-us/forums/intel-math-kernel-library). You'd get the answer for this type of questions within hours instead of days.
I had a similar problem when setting up mingw on windows.
The following library linking order worked for me with gcc:
mkl_intel_thread
mkl_rt
mkl_core
mkl_intel_lp64
Hope this helps anyone stuck with this problem.

Link error: undefined reference to EVP_CIPHER_CTX_ and EVP_CIPHER_CTX_init

I am using crypto++ in my code. I don't want to use its dependencies so i've tried to import crypto++ files in my folder and include them in my .cpp file
I have the followng errors:
TEST.cpp:(.text+0x89a0): undefined reference to `EVP_CIPHER_CTX_init'
TEST.cpp:(.text+0x8cb0): undefined reference to `EVP_aes_128_cbc'
TEST.cpp:(.text+0x8cdd): undefined reference to `EVP_CipherInit_ex'
TEST.cpp:(.text+0x8d49): undefined reference to `EVP_CipherUpdate'
TEST.cpp:(.text+0x8dd6): undefined reference to `EVP_CipherFinal_ex'
TEST.cpp:(.text+0x922d): undefined reference to `EVP_CIPHER_CTX_cleanup'
what am i missing? need some help. Appreciate!
I am working in ubuntu.
You need to do two things, of which you've only done one so far.
You need to tell your compiler where to find the appropriate declarations. You've done this by adding
#include "evp.h"
in your source file. (Depending on how you installed crypto++, you might also need to tell the compiler where to find "evp.h", probably using -Isome_directory.)
The step you're missing is telling the linker where to find the actual implementation (the compiled code) of the functions you're using. According to the Readme.txt file included in the distribution, bulding crypto++ creates a library file called libcryptopp.a.
So something like this should do the job:
gcc my_program.c -o my_program -lcryptopp
Depending on how and where you installed it, you might also need to specify -Lsome_directory to tell the linker where to find libcryptopp.a. (The gcc command invokes both the compiler and the linker. The -l option tells the linker to use libcryptopp.a. The -L option, if needed, tells it what directory to look in.)
TEST.cpp:(.text+0x89a0): undefined reference to `EVP_CIPHER_CTX_init'
TEST.cpp:(.text+0x8cb0): undefined reference to `EVP_aes_128_cbc'
TEST.cpp:(.text+0x8cdd): undefined reference to `EVP_CipherInit_ex'
TEST.cpp:(.text+0x8d49): undefined reference to `EVP_CipherUpdate'
TEST.cpp:(.text+0x8dd6): undefined reference to `EVP_CipherFinal_ex'
TEST.cpp:(.text+0x922d): undefined reference to `EVP_CIPHER_CTX_cleanup'
That's not Crypto++ - its OpenSSL.
If you need to install Crypto++ on Ubuntu, then:
root#bruno:/# apt-cache pkgnames | grep -i crypto++
libcrypto++-utils
libcrypto++8
libcrypto++8-dbg
libcrypto++-dev
libcrypto++-doc
root#bruno:/# apt-get install libcrypto++8 libcrypto++8-dbg libcrypto++-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libcrypto++-dev libcrypto++8 libcrypto++8-dbg
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 10.7MB of archives.
...