Another Rmosek installation problem

888 views
Skip to first unread message

Yuanbin Ru

unread,
Nov 18, 2011, 8:18:53 PM11/18/11
to mosek
Hi,

I read the previous post about Rmosek installation problem, but still
I couldn't figure out what I should do to correctly install Rmosek on
my computer.

The operation system is Ubuntu 10.04.3 LTS (64-bit)
R version is 2.14.0 (2011-10-31)
I have both 32-bit and 64-bit versions of Mosek installed.

Here is my command to install Rmosek:
1. in a linux terminal
$ sudo R

2. in R
> install.packages("Rmosek", repos="http://R-Forge.R-project.org", type="source", INSTALL_opts="--no-multiarch", configure.vars="PKG_MOSEKHOME=/home/ybru/Programs/mosek64/6/tools/platform/linux64x86 PKG_MOSEKLIB=mosek64")
Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://R-Forge.R-project.org/src/contrib/
Rmosek_0.9.5.tar.gz'
Content type 'application/x-gzip' length 432346 bytes (422 Kb)
opened URL
==================================================
downloaded 422 Kb

* installing *source* package ‘Rmosek’ ...
Configuring for a UNIX-alike platform (sub-architecture: "")
Found variable definitions in environment
Using MOSEK home directory: /home/ybru/Programs/mosek64/6/tools/
platform/linux64x86
Using MOSEK library: mosek64
Configuration done.
** libs
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c Rmosek.cc -o Rmosek.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c local_stubs.cc -o local_stubs.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_msg_system.cc -o rmsk_msg_system.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_arguments.cc -o rmsk_obj_arguments.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_constraints.cc -o rmsk_obj_constraints.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_matrices.cc -o rmsk_obj_matrices.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_mosek.cc -o rmsk_obj_mosek.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_sexp.cc -o rmsk_obj_sexp.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_sexp_methods.cc -o rmsk_sexp_methods.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek64/6/tools/
platform/linux64x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_utils.cc -o rmsk_utils.o
g++ -shared -o Rmosek.so Rmosek.o local_stubs.o rmsk_msg_system.o
rmsk_obj_arguments.o rmsk_obj_constraints.o rmsk_obj_matrices.o
rmsk_obj_mosek.o rmsk_obj_sexp.o rmsk_sexp_methods.o rmsk_utils.o -L/
home/ybru/Programs/mosek64/6/tools/platform/linux64x86/bin -lmosek64 -
L/usr/lib64/R/lib -lR
installing to /usr/local/lib/R/site-library/Rmosek/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/site-library/Rmosek/
libs/Rmosek.so':
libmosek64.so.6.0: cannot open shared object file: No such file or
directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/Rmosek’

The downloaded packages are in
‘/tmp/RtmpL5pXND/downloaded_packages’
Warning message:
In install.packages("Rmosek", repos = "http://R-Forge.R-
project.org", :
installation of package ‘Rmosek’ had non-zero exit status

Since I am not sure whether my R is 32-bit or 64-bit, so I also tried
32-bit Rmosek, but no luck:
> install.packages("Rmosek", repos="http://R-Forge.R-project.org", type="source", INSTALL_opts="--no-multiarch", configure.vars="PKG_MOSEKHOME=/home/ybru/Programs/mosek/6/tools/platform/linux32x86 PKG_MOSEKLIB=mosek")
Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://R-Forge.R-project.org/src/contrib/
Rmosek_0.9.5.tar.gz'
Content type 'application/x-gzip' length 432346 bytes (422 Kb)
opened URL
==================================================
downloaded 422 Kb

* installing *source* package ‘Rmosek’ ...
Configuring for a UNIX-alike platform (sub-architecture: "")
Found variable definitions in environment
Using MOSEK home directory: /home/ybru/Programs/mosek/6/tools/platform/
linux32x86
Using MOSEK library: mosek
Configuration done.
** libs
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c Rmosek.cc -o Rmosek.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c local_stubs.cc -o local_stubs.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_msg_system.cc -o rmsk_msg_system.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_arguments.cc -o rmsk_obj_arguments.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_constraints.cc -o rmsk_obj_constraints.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_matrices.cc -o rmsk_obj_matrices.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_mosek.cc -o rmsk_obj_mosek.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_obj_sexp.cc -o rmsk_obj_sexp.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_sexp_methods.cc -o rmsk_sexp_methods.o
g++ -I/usr/share/R/include -I/home/ybru/Programs/mosek/6/tools/
platform/linux32x86/h -I"/usr/lib/R/library/Matrix/include" -fpic -
O3 -pipe -g -c rmsk_utils.cc -o rmsk_utils.o
g++ -shared -o Rmosek.so Rmosek.o local_stubs.o rmsk_msg_system.o
rmsk_obj_arguments.o rmsk_obj_constraints.o rmsk_obj_matrices.o
rmsk_obj_mosek.o rmsk_obj_sexp.o rmsk_sexp_methods.o rmsk_utils.o -L/
home/ybru/Programs/mosek/6/tools/platform/linux32x86/bin -lmosek -L/
usr/lib64/R/lib -lR
/usr/bin/ld: skipping incompatible /home/ybru/Programs/mosek/6/tools/
platform/linux32x86/bin/libmosek.so when searching for -lmosek
/usr/bin/ld: cannot find -lmosek
collect2: ld returned 1 exit status
make: *** [Rmosek.so] Error 1
ERROR: compilation failed for package ‘Rmosek’
* removing ‘/usr/local/lib/R/site-library/Rmosek’

The downloaded packages are in
‘/tmp/RtmpL5pXND/downloaded_packages’
Warning message:
In install.packages("Rmosek", repos = "http://R-Forge.R-
project.org", :
installation of package ‘Rmosek’ had non-zero exit status

Does anybody have any idea what to do?

Thanks a lot!

Yuanbin

Henrik Alsing Friberg

unread,
Nov 21, 2011, 4:35:24 AM11/21/11
to mosek
There are two indicators in your message pointing to the fact that you
are using a 64 bit version of R. One is that the "ldflags" of the
linker is set to "-L/usr/lib64/R/lib -lR". Note that on 32 bit
versions of R, this would not say "lib64".
--------------------

g++ -shared -o Rmosek.so Rmosek.o local_stubs.o rmsk_msg_system.o
rmsk_obj_arguments.o rmsk_obj_constraints.o rmsk_obj_matrices.o
rmsk_obj_mosek.o rmsk_obj_sexp.o rmsk_sexp_methods.o rmsk_utils.o -L/
home/ybru/Programs/mosek/6/tools/platform/linux32x86/bin -lmosek -L/
usr/lib64/R/lib -lR
--------------------

The other indicator is that the mosek library is incompatible when you
are linking to the 32 bit version of it.
--------------------


/usr/bin/ld: skipping incompatible /home/ybru/Programs/mosek/6/tools/
platform/linux32x86/bin/libmosek.so when searching for -lmosek

--------------------

To check what architecture your R is using, you can always write
"R.Version()$arch".
If this is equals something like "i386" or "i686" you are using 32
bit, while 64 bit would typically be "x86_64".


Regarding your problem, I would like to know whether you are able to
run the executable mosek from the command line? If not, please review
the Installation Manual on http://mosek.com/resources/doc/ and contact
MOSEK if you have any troubles getting MOSEK to work. If it does work,
please report the output of the R command
Sys.getenv("LD_LIBRARY_PATH")
which will tell if the mosek libraries are visible from R, and also
report the output of the shell command
mosek -v
which will state the exact version of MOSEK you are using so that I
can replicate your platform settings.

Kind regards,
Henrik Alsing Friberg

Yuanbin Ru

unread,
Nov 21, 2011, 1:14:50 PM11/21/11
to mosek
Thanks for your help, Henrik!

Here is the output in a Linux terminal:

$ mosek -v
MOSEK version 6.0 (Revision: 0 Build 124)
Return code - 0 [MSK_RES_OK]

$ mosek -f

MOSEK Version 6.0.0.124 (Build date: 2011-11-1 12:20:37)
Copyright (c) 1998-2011 MOSEK ApS, Denmark. WWW: http://www.mosek.com
Global optimizer version: 6.1.1.616. Global optimizer build date: Oct
19 2011 15:05:48
Barrier Solver Version 6.0.0.124,
Platform Linux x64.
64 bit architecture.
Using FLEXlm version: 11.10.
Hostname: 'DRTLAB' Hostid: ''

Operating system variables
MOSEKLM_LICENSE_FILE : /home/ybru/Programs/mosek64/6/licenses
LD_LIBRARY_PATH :

/home/ybru/Programs/mosek64/6/tools/platform/linux64x86/bin

*** Warning: No input file specified.
Common usage of the MOSEK command line tool is:

mosek file_name

Return code - 0 [MSK_RES_OK]

--------------------------------------------------------------------

And the following is the output in R:

> R.Version()$arch
[1] "x86_64"
> Sys.getenv("LD_LIBRARY_PATH")
[1] "/usr/lib64/R/lib:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jni"
> Sys.getenv("HOME")
[1] "/home/ybru"

--------------------------------------------------------------------

It seems that the path to mosek is not in LD_LIBRARY_PATH.

But in ~/.bashrc, I did add the lines below:

# environment set up for the Mosek optimization software
MOSEKPLATFORM=linux64x86
export PATH=$PATH:$HOME/Programs/mosek64/6/tools/platform/
$MOSEKPLATFORM/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/Programs/mosek64/6/tools/
platform/$MOSEKPLATFORM/bin
export MOSEKLM_LICENSE_FILE=$HOME/Programs/mosek64/6/licenses
PKG_MOSEKHOME=$HOME/Programs/mosek64/6/tools/platform/$MOSEKPLATFORM
PKG_MOSEKLIB="mosek64"

And I restarted the computer after ~/.bashrc was changed.

I hope the information would help. Thanks!

Best,
Yuanbin

Henrik Alsing Friberg

unread,
Nov 22, 2011, 4:08:59 AM11/22/11
to mosek
Great feedback Yuanbin, now I think we are getting to the core
problem.

The ~/.bashrc file is read every time you open a new bash terminal.
Exported variables affects the entire bash session and typically all
its subprocesses. Unfortunately R is not affected!! You have at least
three ways to fix this so that R can also read the defined variables:

(1) Copy the definitions to the ~/.Rprofile file.
This file is read as an R script when you open a R console. Variables
defined with Sys.setenv will affect the entire R session and typically
all its subprocesses. Use Sys.getenv to get the variable definitions
for PATH and LD_LIBRARY_PATH so you do not overwrite anything - only
append.

(2) Move the definitions to the ~/.profile file.
This file is read when you login to the system, except on some systems
when you login from a bash terminal and the ~/.bash_profile file
exists. Exported variables affects the entire login session.

(3) Move the definitions to the ~/.bash_profile file.
This file is only read when you login to the system from a bash
terminal (typically through ssh tunneling). Exported variables affects
the entire login session.

Hope you find a solution that works for you. You may want to make one
file call the other (remember to check if it exists). Also, you can
use "/etc/profile" or "/etc/environment" instead of "~/.profile" if
you have root access to the system and want the variables to be
defined for all users.

You can read more about this here
https://help.ubuntu.com/community/EnvironmentVariables#Persistent_environment_variables

Yuanbin Ru

unread,
Nov 22, 2011, 5:21:09 PM11/22/11
to mosek
Thanks for the great help, Henrik. I am almost there -- got Rmosek
installed, but failed to load the package afterwards.

Here is what I did:

First, I created ~/.Rprofile with the following content:
---------------------------------
Sys.setenv(MOSEKPLATFORM="linux64x86")
Sys.setenv("PATH" = paste(Sys.getenv("PATH"), ":", Sys.getenv("HOME"),
"/Programs/mosek64/6/tools/platform/", Sys.getenv("MOSEKPLATFORM"), "/
bin", sep=""))
Sys.setenv("LD_LIBRARY_PATH" = paste(Sys.getenv("LD_LIBRARY_PATH"),
":", Sys.getenv("HOME"), "/Programs/mosek64/6/tools/platform/",
Sys.getenv("MOSEKPLATFORM"), "/bin", sep=""))
Sys.setenv("MOSEKLM_LICENSE_FILE" = paste(Sys.getenv("HOME"), "/
Programs/mosek64/6/licenses", sep=""))
Sys.setenv("PKG_MOSEKHOME" = paste(Sys.getenv("HOME"), "/Programs/
mosek64/6/tools/platform/", Sys.getenv("MOSEKPLATFORM"), sep=""))
Sys.setenv(PKG_MOSEKLIB="mosek64")
---------------------------------

Secondly, I tried installing Rmosek in R:
---------------------------------
> install.packages("Rmosek", repos="http://R-Forge.R-project.org", type="source", INSTALL_opts="--no-multiarch")

Warning in library.dynam("Rmosek", pkgname) :
use of library.dynam() without specifying both 'package' and
'lib.loc' is deprecated

* DONE (Rmosek)

The downloaded packages are in

‘/tmp/Rtmpicsyyj/downloaded_packages’
---------------------------------

There was a warning, but Rmosek is finally installed!
Then I tried to load the package, but this was where it failed:
---------------------------------
> require("Rmosek")
Loading required package: Rmosek
Loading required package: Matrix
Loading required package: lattice

Attaching package: ‘Matrix’

The following object(s) are masked from ‘package:base’:

det

Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/site-library/Rmosek/
libs/Rmosek.so':
libmosek64.so.6.0: cannot open shared object file: No such file or
directory

---------------------------------

I checked directory /usr/local/lib/R/site-library/Rmosek/libs/,
Rmosek.so is the only file there. libmosek64.so.6.0 is in /home/ybru/
Programs/mosek64/6/tools/platform/linux64x86/bin, which is defined in
LD_LIBRARY_PATH.

We are almost there, any hope?

Thanks!
Yuanbin

Henrik Alsing Friberg

unread,
Nov 23, 2011, 5:02:27 AM11/23/11
to mo...@googlegroups.com
Hello Yuanbin,

I apologize for having misinformed you.
  Firstly, it seems that the ~/.bashrc may work on some systems after
all. However, since Sys.getenv("LD_LIBRARY_PATH") did not yield the
correct result in your case, we know that the exported ~/.bashrc
definitions were not carried over to the R environment and something
else must be done.
  Secondly, the LD_LIBRARY_PATH variable needs to be correctly set
before the R environment is initialized. Setting it afterwards (either
in the R-console or in ~/.Rprofile) will only change its definition,
not its library loading effect. You are still able to set
PKG_MOSEKHOME and PKG_MOSEKLIB in here if you wish.

With that cleared up, I would like you to try and execute this piece
of code in a linux terminal:
--------------------
MOSEKPLATFORM="linux64x86";
export PKG_MOSEKHOME=$HOME/Programs/mosek64/6/tools/platform/$MOSEKPLATFORM;
export PKG_MOSEKLIB="mosek64";
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/Programs/mosek64/6/tools/platform/$MOSEKPLATFORM/bin;
R


install.packages("Rmosek", repos="http://R-Forge.R-project.org",
type="source", INSTALL_opts="--no-multiarch")

require("Rmosek")
--------------------

The point is that we now go around the troubles of session-wide and
system-wide scripts for environment variables and keep it simple. The
definitions of PKG_MOSEKHOME and PKG_MOSEKLIB should make it possible
to install the package, while the definition of LD_LIBRARY_PATH should
make it possible to load the library without the "libmosek64.so.6.0"
related errors you have been encountering. Please tell me how this
goes around, and feel free to modify the variables definitions if I've
got them wrong..

If the above piece of code works, then indeed you just need to put the
exported variable definitions above in the correct place. (e.g.
~/.profile or ~/.bash_profile)..

Ps. I do not believe the warning you sent me has anything to do with
your installation issues, but I will definitely look into it and find
out what is causing it. I know that with the release of R v2.14 the
use of library.dynam() without specifying all the first three
arguments has been disallowed.

PPs. I noticed that you use the definition
"MOSEKLM_LICENSE_FILE=$HOME/Programs/mosek64/6/licenses". This is not
recommended practice and could cause problems if more files were
present in the referred directory. Instead, MOSEKLM_LICENSE_FILE
should point to the actual license file (e.g.
"$HOME/Programs/mosek64/6/licenses/mosek.lic"). Note, however, that
this has nothing to do with the installation problem and should only
be regarded as a quite side note.

Kind regards
Henrik Alsing Friberg

Yuanbin Ru

unread,
Nov 23, 2011, 12:04:10 PM11/23/11
to mosek
Thank you, Henrik, for the always helpful feedback.

I kept ~/.Rprofile as before and tried the commands you provided.
Rmosek was installed successfully as before. But still loading Rmosek
failed. All output to the R console are the same as before:


--------------------------------
> require("Rmosek")
Loading required package: Rmosek
Loading required package: Matrix
Loading required package: lattice

Attaching package: ‘Matrix’

The following object(s) are masked from ‘package:base’:

det

Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/site-library/Rmosek/
libs/Rmosek.so':
libmosek64.so.6.0: cannot open shared object file: No such file or
directory

> Sys.getenv("LD_LIBRARY_PATH")
[1] "/usr/lib64/R/lib:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/

server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jni:/home/
ybru/Programs/mosek64/6/tools/platform/linux64x86/bin"
--------------------------------

So the problem is still the same: /usr/local/lib/R/site-library/Rmosek/
libs/Rmosek.so cannot be loaded. I am still have no clue what caused
that.


As a practice, if I deleted ~/.Rprofile, and restarted R:
--------------------------------


> install.packages("Rmosek", repos="http://R-Forge.R-project.org",

+ type="source", INSTALL_opts="--no-multiarch")


Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://R-Forge.R-project.org/src/contrib/
Rmosek_0.9.5.tar.gz'
Content type 'application/x-gzip' length 432346 bytes (422 Kb)
opened URL
==================================================
downloaded 422 Kb

* installing *source* package ‘Rmosek’ ...
Configuring for a UNIX-alike platform (sub-architecture: "")

*** No variable 'PKG_MOSEKHOME' in environment - see configure-vars
(configure.vars) argument ***
*** No variable 'PKG_MOSEKHOME' in ./src/setup/Localsys.txt file ***
*** Shell command 'mosek' was not recognized - please validate your
installation of MOSEK ***
*** >> PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/
sbin:/bin:/usr/X11R6/bin ***
ERROR: configuration failed for package ‘Rmosek’
* removing ‘/usr/local/lib/R/site-library/Rmosek’
* restoring previous ‘/usr/local/lib/R/site-library/Rmosek’

The downloaded packages are in

‘/tmp/Rtmp0Pa0aG/downloaded_packages’


Warning message:
In install.packages("Rmosek", repos = "http://R-Forge.R-
project.org", :
installation of package ‘Rmosek’ had non-zero exit status

--------------------------------

So this means that PKG_MOSEKHOME and PATH defined in ~/.Rprofile were
actually loaded when R started.

Thanks for your help, Henrik! And sorry to have bothered you for so
long.

Yuanbin


On Nov 23, 3:02 am, Henrik Alsing Friberg

Henrik Alsing Friberg

unread,
Nov 24, 2011, 2:42:23 AM11/24/11
to mosek
Hi Yuanbin,

This is a tricky problem. Try to print the dependencies of the
installed shared library Rmosek.so, which can not be loaded. This can
be done with the following R commands:
--------------------
pkg_libfile = system.file("libs", "Rmosek.so", package="Rmosek")
system(paste("ldd", pkg_libfile))
--------------------

In your case the pkg_libfile variable should equal '/usr/local/lib/R/
site-library/Rmosek/libs/Rmosek.so'.

Yuanbin Ru

unread,
Nov 28, 2011, 1:31:03 PM11/28/11
to mosek
Hi Henrik,

Hope you had a nice Thanksgiving.

As for the Rmosek problem I had, I still don't know what to do.
Here is the output of the R commands you suggested:

--------------------
> pkg_libfile = system.file("libs", "Rmosek.so", package="Rmosek")

> pkg_libfile
[1] "/usr/local/lib/R/site-library/Rmosek/libs/Rmosek.so"
> system(paste("ldd", pkg_libfile))
linux-vdso.so.1 => (0x00007fffff387000)
libmosek64.so.6.0 => /home/ybru/Programs/mosek64/6/tools/platform/
linux64x86/bin/libmosek64.so.6.0 (0x00007fc7c855e000)
libR.so => /usr/lib64/R/lib/libR.so (0x00007fc7c7fff000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fc7c7cd2000)
libm.so.6 => /lib/libm.so.6 (0x00007fc7c7a4f000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fc7c7837000)
libc.so.6 => /lib/libc.so.6 (0x00007fc7c74b4000)
libiomp5.so => /home/ybru/Programs/mosek64/6/tools/platform/
linux64x86/bin/libiomp5.so (0x00007fc7c7324000)
libdl.so.2 => /lib/libdl.so.2 (0x00007fc7c711f000)
libblas.so.3gf => /usr/lib/libblas.so.3gf (0x00007fc7c6e84000)
libgfortran.so.3 => /usr/lib/libgfortran.so.3 (0x00007fc7c6b97000)
libreadline.so.6 => /lib/libreadline.so.6 (0x00007fc7c6955000)
libpcre.so.3 => /lib/libpcre.so.3 (0x00007fc7c6727000)
liblzma.so.1 => /usr/lib/liblzma.so.1 (0x00007fc7c6506000)
libbz2.so.1.0 => /lib/libbz2.so.1.0 (0x00007fc7c62f4000)
libz.so.1 => /lib/libz.so.1 (0x00007fc7c60dd000)
librt.so.1 => /lib/librt.so.1 (0x00007fc7c5ed5000)
libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007fc7c5cc6000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007fc7c5aa9000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc7c91d1000)
libncurses.so.5 => /lib/libncurses.so.5 (0x00007fc7c5865000)
--------------------

I also print the dependencies of libmosek64.so.6.0:
--------------------
> system("ldd /home/ybru/Programs/mosek64/6/tools/platform/linux64x86/bin/libmosek64.so.6.0")
linux-vdso.so.1 => (0x00007fffc64cf000)
libiomp5.so => /home/ybru/Programs/mosek64/6/tools/platform/
linux64x86/bin/libiomp5.so (0x00007faec3a0c000)
libc.so.6 => /lib/libc.so.6 (0x00007faec366f000)
libdl.so.2 => /lib/libdl.so.2 (0x00007faec346b000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007faec324e000)
/lib64/ld-linux-x86-64.so.2 (0x00007faec45d9000)
--------------------

I hope these could help. Thanks a lot!

Best,
Yuanbin

Henrik Alsing Friberg

unread,
Nov 29, 2011, 4:01:04 AM11/29/11
to mosek
Hi Yuanbin, hope you had a nice Thanksgiving too.

To sum up the problem, the original error was
--------------------


Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/site-library/Rmosek/
libs/Rmosek.so':
libmosek64.so.6.0: cannot open shared object file: No such file or
directory

--------------------

We found a solution to specify Sys.getenv("LD_LIBRARY_PATH")
correctly, and furthermore have now established that there are no
undefined dependencies in Rmosek.so. Especially, the library that was
supposedly causing the problems (libmosek64.so.6.0) is defined as
shown here which I assume is correct.
--------------------


libmosek64.so.6.0 => /home/ybru/Programs/mosek64/6/tools/platform/
linux64x86/bin/libmosek64.so.6.0 (0x00007fc7c855e000)

--------------------

So my last guess is that it has something to do with ownership and
permissions of the respective files. In particular, I noticed that you
wrote "sudo R" in your very first post. I is not unlikely that the
mixture of user and super user rights have caused problems. Try to
check your MOSEK, R and Rmosek installations, or redo them all taking
special care to this issue. Otherwise I would recommend you to install
all of this on a fresh linux installation in case your OS has been
tainted in some way. Unfortunately, this is out of my league and I
will almost certainly be unable to help you through this. I wish you
the best of luck, and hope that you will figure this one out.

Kind regards,
Henrik Alsing Friberg

Yuanbin Ru

unread,
Nov 30, 2011, 12:34:05 PM11/30/11
to mosek
Hi Henrik,

I really appreciate your time and help.

I finally found the solution, not a neat one, but it worked.

Here is the R commands:

--------------------
> dyn.load("/home/ybru/Programs/mosek64/6/tools/platform/linux64x86/bin/libiomp5.so")
> dyn.load("/home/ybru/Programs/mosek64/6/tools/platform/linux64x86/bin/libmosek64.so.6.0")
> require(Rmosek)


Loading required package: Rmosek
Loading required package: Matrix
Loading required package: lattice

Attaching package: ‘Matrix’

The following object(s) are masked from ‘package:base’:

det

Warning in library.dynam("Rmosek", pkgname) :


use of library.dynam() without specifying both 'package' and
'lib.loc' is deprecated

--------------------

The trick is to load libiomp5.so, which is required by libmosek64.so.
6.0, and libmosek64.so.6.0. These two libraries are needed for Rmosek
to load. But each time I want to use Rmosek, I have to load the two
libraries first. It may be a better way -- like you said it has
something to do with ownership and permissions.

Then I tested the two examples at http://rmosek.r-forge.r-project.org/.
The first example that uses interior-point optimizer ran smoothly. The
second example failed:

--------------------
> modelfile <- system.file(package="Rmosek", "extdata", "milo1.opf")
> rr <- mosek_read(modelfile)
Open file '/usr/local/lib/R/site-library/Rmosek/extdata/milo1.opf'
> if (is.null(rr) || !identical(rr$response$code, 0))
+ stop("Failed to read model file")
> rmilo1 <- mosek(rr$prob)
Computer - Platform : Linux/64-X86
Computer - CPU type : Intel-P4
MOSEK - task name :
MOSEK - objective sense : max
MOSEK - problem type : LO (linear optimization problem)
MOSEK - constraints : 2
variables : 2
MOSEK - integer variables : 2
Optimizer started.
MOSEK Error 1553 : The mixed-integer optimizer is not loaded.
Optimizer terminated. Time: 0.00
Optimization interrupted.
ERROR: MSK_RES_ERR_MIO_NOT_LOADED: The mixed-integer optimizer is not
loaded.
--------------------

Probably it still has something to do with path, ownership and
permissions.

Thanks!
Yuanbin

Henrik Alsing Friberg

unread,
Dec 1, 2011, 3:24:41 AM12/1/11
to mosek
Hi Yuanbin,

I tried to remove my definition of LD_LIBRARY_PATH, relogin to the
system, and install the Rmosek package from scratch afterwards. The
package installed just fine, but I got the exact same error message as
you when I tried to load it (the one with "...libmosek64.so.6.0:
cannot open shared object file..."). Again, this shows that the
availability of the LD_LIBRARY_PATH (or the visibility/permissions/
etc. of the libraries it points to), is your main issue when R is
loaded. Once R is loaded, new definitions of LD_LIBRARY_PATH will have
no effect. Does your version of R by any chance have preloading of any
kind? In that case, you would have to set the LD_LIBRARY_PATH before
that. I have never heard of anything like it, but I am trying to
pinpoint the problem.

The mixed-integer optimizer is loaded dynamically (not statically),
and therefore I do not think this dependency can be fixed with the
"dyn.load" function, even if all libraries in the 'bin' folder were
loaded this way. However, since I was able to replicate your situation
I was also able to figure out another "hack". Just set the working
directory with the "setwd" function to the "bin" folder. It should
look something like:
setwd("/home/ybru/Programs/mosek64/6/tools/platform/linux64x86/bin")

If all works here, you may be able to recreate the solution in other
directories by providing copies or symbolic links to the libraries. I
do believe that it is one ugly "hack", and that you should try to
address the core issues with the LD_LIBRARY_PATH instead.

Kind regards,
Henrik Alsing Friberg


On 30 Nov., 18:34, Yuanbin Ru <ruyuan...@gmail.com> wrote:
> Hi Henrik,
>
> I really appreciate your time and help.
>
> I finally found the solution, not a neat one, but it worked.
>
> Here is the R commands:
>
> --------------------> dyn.load("/home/ybru/Programs/mosek64/6/tools/platform/linux64x86/bin/libiomp5.so")
> > dyn.load("/home/ybru/Programs/mosek64/6/tools/platform/linux64x86/bin/libmosek64.so.6.0")
> > require(Rmosek)
>
> Loading required package: Rmosek
> Loading required package: Matrix
> Loading required package: lattice
>
> Attaching package: ‘Matrix’
>
> The following object(s) are masked from ‘package:base’:
>
>     det
>
> Warning in library.dynam("Rmosek", pkgname) :
>   use of library.dynam() without specifying both 'package' and
> 'lib.loc' is deprecated
> --------------------
>
> The trick is to load libiomp5.so, which is required by libmosek64.so.
> 6.0, and libmosek64.so.6.0. These two libraries are needed for Rmosek
> to load. But each time I want to use Rmosek, I have to load the two
> libraries first. It may be a better way -- like you said it has
> something to do with ownership and permissions.
>

> Then I tested the two examples athttp://rmosek.r-forge.r-project.org/.

Yuanbin Ru

unread,
Dec 1, 2011, 2:04:01 PM12/1/11
to mosek
Hi Henrik,

I think everything works well now. There are 2 key files here.

1. Only ~/.Rprofile is required for Rmosek installation. Here is the
commands I added to this file:


Sys.setenv(MOSEKPLATFORM="linux64x86")
Sys.setenv("PATH" = paste(Sys.getenv("PATH"), ":",
Sys.getenv("HOME"), "/Programs/mosek64/6/tools/platform/",

Sys.getenv("MOSEKPLATFORM"), "/bin", sep=""))

Sys.setenv("LD_LIBRARY_PATH" =
paste(Sys.getenv("LD_LIBRARY_PATH"), ":", Sys.getenv("HOME"), "/


Programs/mosek64/6/tools/platform/", Sys.getenv("MOSEKPLATFORM"), "/
bin", sep=""))

Sys.setenv("MOSEKLM_LICENSE_FILE" = paste(Sys.getenv("HOME"), "/

Programs/mosek64/6/licenses/mosek.lic", sep=""))


Sys.setenv("PKG_MOSEKHOME" = paste(Sys.getenv("HOME"), "/Programs/
mosek64/6/tools/platform/", Sys.getenv("MOSEKPLATFORM"), sep=""))
Sys.setenv(PKG_MOSEKLIB="mosek64")

2. Only ~/.bashrc is required for Rmosek to load and function. Here is
the commands I added to the file:


MOSEKPLATFORM=linux64x86
export PATH=$PATH:$HOME/Programs/mosek64/6/tools/platform/
$MOSEKPLATFORM/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/Programs/mosek64/6/
tools/platform/$MOSEKPLATFORM/bin

export MOSEKLM_LICENSE_FILE=$HOME/Programs/mosek64/6/licenses/
mosek.lic
PKG_MOSEKHOME=$HOME/Programs/mosek64/6/tools/platform/
$MOSEKPLATFORM
PKG_MOSEKLIB="mosek64"

During installation of Rmosek, only ~/.Rprofile was needed since I
commented out the MOSEK settings in ~/.bashrc.
Then when I tried to load Rmosek in R, I did not remove the #'s in
front of all the MOSEK settings in ~/.bashrc, so the loading of Rmosek
failed. Even we did the trick using dyn.load() or setwd() and Rmosek
was loaded, the 2nd example at http://rmosek.r-forge.r-project.org/
was not successful.

Then I added the MOSEK settings back to ~/.bashrc, restarted the
computer, and tried to load Rmosek and run the 2 examples above. All
were good! It turned out that ~/.Rprofile is not needed for loading
and functioning of Rmosek, because removing ~/.Rprofile did not affect
Rmosek to load and execute.

So all are good now. Maybe for the installation manual, you could add
a specific section for Ubuntu, saying that ~/.Rprofile is required for
installation of Rmosek and ~/.bashrc is required for the Rmosek
package to load and function.

Thanks so much for your time and hard work, Henrik! It took us so long
to figure things out. I really appreciate your effort and patience!

Best,
Yuanbin

l...@ualberta.ca

unread,
Apr 30, 2012, 9:43:38 PM4/30/12
to mo...@googlegroups.com
Hi Henrik,

I am not sure whether you are familiar with Rmosek in Windows x64 system.

I wanna install Rmosek in my windows computer, I got mosek installed and tested (it works as I typed mosek -f in command line), I got R 2.14.2 as well as R tools, but when I install the package Rmosk in R by typing: install.packages("Rmosek", type="source", INSTALL_opts="--no-multiarch"),

 I got the following errors from R:

将程序包安装入‘C:/Users/linmusoccer/Documents/R/win-library/2.14’
(因为‘lib’没有被指定)
试开URL’http://cran.stat.sfu.ca/src/contrib/Rmosek_1.2.2.tar.gz'
Content type 'application/x-gzip' length 431308 bytes (421 Kb)
打开了URL
downloaded 421 Kb


* installing *source* package 'Rmosek' ...
** 成功将'Rmosek'程序包解包并MD5和检查
Configuring for the Windows platform (sub-architecture: "/x64")
cygwin warning:
  MS-DOS style path detected: C:/PROGRA~1/R/R-214~1.2/bin/Rscript
  Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-214~1.2/bin/Rscript
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Found package 'Matrix' version 1.0.5
Guessed variable definitions from command 'mosek' in Windows CMD
Using MOSEK home directory: C:\Program Files\Mosek\6\tools\platform\win64x86
Using MOSEK library: mosek64_6_0
Configuration done.
** libs
警告: this package has a non-empty 'configure.win' file,
so building only the main architecture

cygwin warning:
  MS-DOS style path detected: C:/PROGRA~1/R/R-214~1.2/etc/x64/Makeconf
  Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-214~1.2/etc/x64/Makeconf
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
g++ -m64 -I"C:/PROGRA~1/R/R-214~1.2/include" -IC:/Program\ Files/Mosek/6/tools/platform/win64x86/h   -I"C:/Users/linmusoccer/Documents/R/win-library/2.14/Matrix/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall  -mtune=core2 -c Rmosek.cc -o Rmosek.o
Rmosek.cc:1:0: sorry, unimplemented: 64-bit mode not compiled in
compatibility/fallbacks.h:56:19: warning: 'MSK4::Matrix_DimSym' defined but not used
compatibility/fallbacks.h:57:19: warning: 'MSK4::Matrix_iSym' defined but not used
compatibility/fallbacks.h:58:19: warning: 'MSK4::Matrix_jSym' defined but not used
compatibility/fallbacks.h:59:19: warning: 'MSK4::Matrix_xSym' defined but not used
compatibility/fallbacks.h:60:19: warning: 'MSK4::Matrix_uploSym' defined but not used
compatibility/fallbacks.h:61:19: warning: 'MSK4::Matrix_diagSym' defined but not used
make: *** [Rmosek.o] Error 1
ERROR: compilation failed for package 'Rmosek'
* removing 'C:/Users/linmusoccer/Documents/R/win-library/2.14/Rmosek'

下载的程序包在
        ‘C:\Users\linmusoccer\AppData\Local\Temp\RtmpuSiBjY\downloaded_packages’里
警告信息:
1: 运行命令'C:/PROGRA~1/R/R-214~1.2/bin/x64/R CMD INSTALL -l "C:/Users/linmusoccer/Documents/R/win-library/2.14"   C:\Users\LINMUS~1\AppData\Local\Temp\RtmpuSiBjY/downloaded_packages/Rmosek_1.2.2.tar.gz'的状态是1
2: In install.packages("Rmosek", type = "source") :
  安装程序包‘Rmosek’时退出狀態的值不是0

I am sorry that my system language is chinese, but as you can read, the most important information (Configuration is done but still some errors after that) above is english, I also tried the manual configuration from http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/inst/doc/userguide.pdf?root=rmosek, but I cannnot get Rmosek installed either.

I really appretiate if you could help me over this problem, any suggestions or hints will be helpful:)

Thank you very much!

在 2011年12月1日星期四UTC-7上午1时24分41秒,Henrik Alsing Friberg写道:

Henrik Alsing Friberg

unread,
May 1, 2012, 3:23:47 AM5/1/12
to mo...@googlegroups.com

Hi Anonymous,

I hope it is alright that I have answered you in a new thread, where you can also add your response:
https://groups.google.com/d/msg/mosek/qE2r9aa6itQ/SyBUhW-uxSkJ

Kind regards,
Henrik Alsing Friberg.
Reply all
Reply to author
Forward
0 new messages