I am trying to install Google Test according to this answer on Ubuntu without root access, as I need learn and use it at work.
Managed to get these done in my own user folder:
$ mkdir ~/temp
$ cd ~/temp
$ unzip gtest-1.7.0.zip
$ cd gtest-1.7.0
$ mkdir mybuild
$ cd mybuild
$ cmake -DBUILD_SHARED_LIBS=ON -Dgtest_build_samples=ON -G"Unix Makefiles" ..
$ make
It seems I already have gtest in /usr/src/gtest altough I don't want to use this, because it was not me who installed it and I'm not sure about its version, nor in its availability. Can't even delete it without permission.
Still the instruction ends as:
$ cp -r ../include/gtest ~/usr/gtest/include/
$ cp lib*.so ~/usr/gtest/lib
What am I missing here?
Let's say you want to install googletest in /home/me/googletest.
Browse to the googletest GitHub repo https://github.com/google/googletest. (Do not use a possibly -out-of-date version you may have got elsewhere.)
Using the Clone or Download link, either clone or download-and-extract
the source as (let's say) ./googletest under your current directory CWD (where CWD is not /home/me/).
Then in CWD:-
$ mkdir googletest_build
$ cd googletest_build
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/me/googletest ../googletest
$ make
$ make install
After this, you will find:-
/home/me/googletest/
lib/
libgmock.a
libgmock_main.a
libgtest.a
libgtest_main.a
include/
gmock/
# gmock header files
gtest/
# gtest header files
You can then use gtest/gmock headers in your source code like:
#include <gtest/gtest.h>
#include <gmock/gmock.h>
and compile and link a gtest/gmock program like:
g++ -pthread -I/home/me/googletest/include -c -o my-unit-tester.o my-unit-tester.cpp
g++ -o my-unit-tester my-unit-tester.o -L/home/me/googletest/lib -lgtest -lgmock -pthread
using the -I... option to tell the compiler where gtest/gmock headers reside and
using the -L... option to tell the linker where gtest/gmock libraries reside.
Pass -pthread to both compiler and linker because the gtest/gmock libraries are
built multi-threading by default.
After installing you no longer need either CWD/googletest or CWD/googletest_build.
You may wish to pass additional options to cmake, in which case the build products will differ as per the meaning of those additional options.
Related
In this case, it's GPG that I'm trying to build. Basically, I want to have all the build output go into a subdirectory of my choosing, instead of being installed on my live filesystem.
Setting --prefix=path/to/my/sandbox sends the output of one build where I want it to go, but the next build stage, which depends on the output of the previous build stage, can't find that output.
Example:
$ cd libgpg-error-1.37
$ ./configure --prefix=/Users/falk/GpgSandbox/usr/local
$ make
$ make install
(success: all output placed in /Users/falk/GpgSandbox/usr/local/)
$ cd ../libassuan-2.5.3
$ ./configure --prefix=/Users/falk/GpgSandbox/usr/local
...
configure: error: libgpg-error was not found
$
Is there another option I could have passed to ./configure to get it to find libraries in the sandbox? Should I build inside a VM or a docker container?
Many thanks to #hyde for pointing me in the right direction. The solution was to set a few environment variables before building:
mkdir -p /Users/falk/GpgSandbox/usr/local/
export CPPFLAGS='-I/Users/falk/GpgSandbox/usr/local/include'
export LDFLAGS='-L/Users/falk/GpgSandbox/usr/local/lib'
export PATH="$PATH:/Users/falk/GpgSandbox/usr/local/bin"
cd libgpg-error-1.37/
./configure --prefix=/Users/falk/GpgSandbox/usr/local
make install
(etc.)
I am compiling a theorem prover on cygwin and I get this error:
$ make
ocamlmklib -o bin/minisatinterface minisat/core/Solver.o minisat/simp/SimpSolver
.o bin/Ointerface.o -lstdc++
** Fatal error: Error while reading minisat/core/Solver.o: Sys_error("Invalid ar
gument")
Makefile:49: recipe for target `bin/libminisatinterface.a' failed
make: *** [bin/libminisatinterface.a] Error 2
It is not clear what kind of invalid argument is here?
The only documentation I have found for ocamlmklib did not help on understanding the error message. Could it not read the file itself or there is a problem with the contents? ls does list the file:
$ ls -l minisat/core/Solver.o
-rw-r--r-- 1 gbuday mkpasswd 2096 jan. 22 10.42 minisat/core/Solver.o
update: if I remove Solver.o I get a different error message:
** Fatal error: Cannot find file "minisat/core/Solver.o"
So the above error message is about the contents of the object file.
I happen to know that this specifically has to do with the build of the ATP Satallax, which can be used with Isabelle Sledgehammer, and I was asked to look at this.
I have no expertise with make files and ocaml. My success at building Satallax v2.7 came purely from following the instruction in INSTALL, with some minimal ability at guessing at what error codes meant, which I mainly needed when building Satallax v2.6 over a year ago.
The first important thing to do is make sure that the tar file is unzipped while working in a Cygwin terminal, rather than under Windows with something like WinZip.
Assuming that you're working in a Cygwin terminal, these are the notes which I made. After that I'll include text from the Satallax INSTALL, and few comments.
Sources: http://www.ps.uni-saarland.de/~cebrown/satallax/
0) tar xvzf satallax-2.7.tar.gz
1) Cygwin Package (these are also for other's like Leo-II):
zlib-devel, make, OCaml devel, gcc devel, g++ devel, libstdc++6-devel
Ubuntu 12 Packages:
sudo apt-get install build-essential
zlibg-dev using the Ubuntu Software Center
ocaml and g++ if they don't come with "build-essential"
2) Put eprover.exe in the path so that ./configure can find it.
a) There are the following lines in the configure files, which shows
that it's configured to find picomus, eprover has to be in the path
or `which eprover` has to be edited.
# Optionally set picomus to your picomus executable
picomus=${PWD}/picosat-936/picomus
# Optionally set eprover to your E theorem prover executable
eprover=`which eprover`
3) Follow the instructions in INSTALL.
a) export MROOT=`pwd` takes care of this next note, which I had to do
for v2.6, info I keep in here in case I need it in the future.
b) export MROOT=<minisat-dir>, where you replace "minisat-dir" with the
/cygdrive/e\E_2\binp\isaprove\satallax-2.6\cygwin\minisat
3) OLD v2.6 NOTE: If you get an error, delete the old source and try
untaring the sources again.
My build of v2.7 went through without problems, other than the test giving errors.
With Satallax v2.7, there is now the requirement that the build find the eprover. Note STEP 3 of INSTALL tells you to modify configure, or put eprover.exe in the path before the build. I put it in the path, which for me is
E:\E_2\dev\Isabelle2013-2\contrib\e-1.8\x86-cygwin
The INSTALL file then gives short instructions:
* Short Instructions
cd minisat
export MROOT=`pwd`
cd core
make Solver.o
cd ../simp
make SimpSolver.o
cd ../../picosat-936
./configure
make
cd ..
./configure
make
./test | grep ERROR
After downloading all needed packages, and putting eprover.exe in the path, it built without errors for me other than the test, but the executable works when used by Isabelle Sledgehammer.
STEP 3 of INSTALL talks about providing the location of the picomus executable, but I'm pretty sure that there's not need to do that because picosat-936\picomus.exe gets built in this build.
If you watch the build messages, it'll tell you what it's looking for and what it finds.
For completeness, I include the text from INSTALL, except for the instructions related to what's pertinent for Coq.
There are a number of requirements in order to compile Satallax.
In short, you need make, ocaml, g++ and the zlib header files.
In Debian and derived Linux systems, you can get these from
the build-essential and zlib1g-dev packages. You need
ocamlopt to obtain a standalone executable.
If you're not the administrator of the computer on which you're installing,
you can quote the previous paragraph to the administrator.
* Short Instructions
cd minisat
export MROOT=`pwd`
cd core
make Solver.o
cd ../simp
make SimpSolver.o
cd ../../picosat-936
./configure
make
cd ..
./configure
make
./test | grep ERROR
./bin/satallax.opt is the native code executable to use.
See test for examples of how to use it.
* Long Instructions
STEP 1:
Compile minisat (see minisat/README)
cd minisat
export MROOT=<minisat-dir> (or setenv in cshell)
cd core
make Solver.o
cd ../simp
make SimpSolver.o
cd ../..
STEP 2 (Optional. Only needed to extract proof information for proof terms.) :
Build picosat (including picomus):
cd picosat-936
./configure
make
cd ..
STEP 3:
If desired, edit the configure script to give the location of your picomus
and eprover executables. (If the executables are not found by the configure script,
you will need to give the location of the executables to satallax via the command line
options -P <picomus> -E <eprover> if they are needed.)
Run the configure script for Satallax.
./configure
STEP 4:
make
uses ocamlopt to make a standalone executable
./bin/satallax.opt
and uses ocamlc to make a bytecode executable
./bin/satallax
that depends on ocamlrun
STEP 5:
Test satallax using the examples in the script file:
./test
As long as you don't see a line with the word ERROR, it should be working.
I have downloaded gcc-4.1.2 from http://gcc.petsads.us/releases/gcc-4.1.2/gcc-4.1.2.tar.bz2 and built with two commands
./configure
make
Now I can see g++ binary. But there is no gcc binary.
$ ls /opt/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/g++
/opt/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/g++
$ ls /opt/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/gcc
ls: cannot access /opt/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/gcc: No such file or directory
What did I miss?
The gcc binary is called xgcc until it is installed.
did you check whether configure and make went without error?
but less probable: did you run also make install which should install all binaries into appropriate directories?
I am following openmpi install file.
Firstly, I am a normal user in this linux system. I do not have rights to access /usr/local . If I configure with:
./configure --prefix=/usr/local
make will complain about permission.
Therefore, I put the place to install in some other directory (let's call it directory 'A'), and then make install .
I got all the files in the bin and such. I got mpic++, mpicc, etc. in the bin folder and such, in the directory 'A'.
Now, the thing is when I need to compile other programs:
Compiling MPI Applications
==========================
MPI applications should be compiled using the Open MPI "wrapper"
compilers:
C programs: mpicc your-code.c
C++ programs: mpiCC your-code.cc or
mpic++ your-code.cc (for case-insensitive filesystems)
This is from the INSTALL file. The thing is bash complains that mpicc command is not found when I type in "mpicc".
OpenMPI is a dependency for the other programs I am trying to compile, and they invoke OpenMPI by using 'mpicc' command.
What can I do in this case?
Your folder A needs to be on your PATH environment variable. In bash, you would do:
export PATH=/path/to/my/folder/A/bin:$PATH
which will let you just type mpicc. Alternatively, you can use the full path as your command:
/path/to/my/folder/A/bin/mpicc myFile.c
If you don't have write access to the default prefix file tree /usr/local/ you should ./configure with an explicit writable prefix, e.g.
./configure --prefix=$HOME/pub
of course, you could mkdir $HOME/pub then should add $HOME/pub/bin to your PATH
I'm trying to install GCC into /my/custom/path/gcc
but for some reason it installs into the normal installation path.
the commands i'm using:
configure --target=i686-pc-linux-gnu --disable-nls --enable-languages=c,c++ --without-headers
make DESTDIR=/my/custom/path/gcc
make DESTDIR=/my/custom/path/gcc install
What am I doing wrong?
You should run (in a new build tree outside of the source tree)
/your/source/path/to/gcc/configure --target=i686-pc-linux-gnu --prefix=/my/custom/path/gcc ...
and then GCC will become installed in /my/custom/path/gcc/bin/ with include files in /my/custom/path/gcc/include/, libraries in /my/custom/path/gcc/lib/ etc etc
I suggest using /opt/ or $HOME/pub as your prefix and you might also be interested by the --program-suffix=-foo option
(do that in a fresh new build tree outside of the source tree; your previous one is rotten)
After successive compilation with make, you can run in your build tree
make install DESTDIR=/tmp/mygccinst/
and finally, you can copy the definitive files with something like
cp -va /tmp/mygccinst/ /
You may need to run this copy as root...
PS the installation prefix is built-in the gcc driver binary, which actually runs cc1 or cc1plus etc...