Installing Z3 with OCaml bindings - installation

I'm trying to install Z3 with OCaml bindings and getting the following error.
cp ../src/api/ml/z3.mli api/ml/z3.mli
ocamlc -I api/ml -o api/ml/z3.cmi -c api/ml/z3.mli
File "api/ml/z3.mli", line 1159, characters 35-50:
Error: Unbound module Big_int
make: *** [api/ml/z3.cmo] Error 2
I firstly tried installing via
opam install z3
And then I tried cloning the Z3 repo and running
python scripts/mk_make.py --ml
cd build
make
After which I get the same error.
Any help would be greatly appreciated. Thank you!

The Z3 installation is expecting an older OCaml environment. In recent OCaml releases, Big_int is in the Num module.
$ opam install num
For what it's worth, I don't believe there is an OPAM module for Z3. If you run the Z3 install, the OCaml/Z3 interface gets installed as if it was an OPAM module (in ~/.opam). But it's not really.
I'm using Z3 every day, so I can verify that it works (both OCaml 4.03.0 and OCaml 4.06.0.)
Update
I just now verified that there is a Z3 package in OPAM these days, and I was able to install it under OCaml 4.06.0 on a previously clean system that I happen to have handy. The system is Ubuntu 14.04.
I needed to do the following initial installations:
sudo apt-get update
sudo apt-get install ocaml
sudo apt-get install m4
sudo apt-get install dev-libgmp
sudo apt-get install g++
Then I installed OPAM:
sudo add-apt-repository ppa:avsm/ppa
sudo apt-get update
sudo apt-get install opam
Now running as myself:
$ opam init
$ eval `opam config env`
$ opam update
$ opam switch 4.06.0
$ eval `opam config env`
$ opam install z3
$ ls ~/.opam/4.06.0/lib/z3
dllz3ml.so z3.cmi z3enums.cmx z3ml.cmxa z3native.cmx
libz3ml.a z3.cmo z3enums.mli z3ml.cmxs z3native.mli
libz3.so z3.cmx z3enums.o z3.mli z3native.o
META z3enums.cmi z3ml.a z3native.cmi z3native_stubs.o
opam.config z3enums.cmo z3ml.cma z3native.cmo z3.o
This looks good to me. I'm not a Z3 wizard; it's mostly just a dependency of a project I'm working on. But these are the files I'm used to seeing.

Related

An issue with installation of ansible-pylibssh on Apple Silicon M2

I've got an issue with installation of ansible-pylibssh.
During installation
pip3 install --user ansible-pylibssh
I got
ld: library not found for -lssh
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit code 1
Could someone explain how to overcome this?
I've already done softlink
% cd /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
% sudo ln -s /opt/homebrew/Cellar/libssh/0.10.4/include/libssh/ libssh
Install libssh:
brew install libssh
Use a python virtual environment :
python3 -m venv .venv
source .venv/bin/activate
EDIT:
Install with correct compiler flags:
CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh" pip install ansible-pylibssh
Thanks, #webknjaz!
OLD Additional steps not needed (preserved for history):
Install tox build tool:
pip install 'tox >= 3.19.0'
Build from source on ARM-based Macs, per the ansible-pylibssh docs:
#git clone https://github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
# or, if you use SSH:
git clone ssh://git#github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
cd ~/src/github/ansible/pylibssh
Use libraries installed by brew with clang:
export CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh"
Build ansible-pylibssh:
tox -e build-dists
Install built ansible-pylibssh wheel:
pip install ~/src/github/ansible/pylibssh/dist/ansible_pylibssh*.whl
Additional resources that lead to this answer:
Kristof Rado's answer to Cannot install ansible-pylibssh on macOS
ansible/pylibssh GitHub issue 207 provides background on why this package is not available for macOS on ARM from PyPi (symlink/softlink to point to the libraries did not help. Correct compiler flags were the needed answer.)
If you prefer not to work with a virtual environment, this may work: replace pip commands python3 -m pip --user and python commands with python3.

Problems using opam and ocaml

I am working on RDP having Ubuntu 14.04 and trying to install ocaml.
I am trying to update my ocaml compiler to 4.05.0 or above but opam switch list gives only one compiler system C system System compiler (4.01.0). Also my opam update gives me below log.
[ERROR] Your version of OPAM (1.1.1) is not recent enough to read ~/.opam/repo/default/repo. Upgrade OPAM to a more recent version (at least 2.0) to read this file correctly.
[ERROR] Skipping https://opam.ocaml.org as the repository is not available.
Updating ~/.opam/repo/compiler-index ...
Updating ~/.opam/compilers/ ...
Updating ~/.opam/repo/package-index ...
Updating ~/.opam/packages/ ...
Updating the cache of metadata (~/.opam/state.cache) ...
Everything is up-to-date.
Any idea how to do this? Thanks for help in advance.
UPDATE:
I need to install newer opam version separately using binary distribution. with this
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
command I can install it but it will prompt me where to install it,
but I have to automate installation so that there is no interaction from user side. Is there a way to do it?
UPDATE 2:
found a way to do it using ppa see my answer.
Well, as the log says you have to update your OPAM to 2.x. The old version is no longer supported. So you have to follow the installation instructions and update your OCaml.
I tried using sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) but failed in doing it as non-interactive script.
I have found this method which does work, though using Ubuntu 14.04 adding ppa sudo add-apt-repository ppa:avsm/ppa and then doing update, upgrade, dist-upgrade and finally installation of opam will be of version 2.2 (latest as by ppa). Follow below commands for exact procedure.
add-apt-repository ppa:avsm/ppa
apt-get update -y
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get install curl build-essential m4 zlib1g-dev libssl-dev ocaml ocaml-native-compilers opam -y
opam init --disable-sandboxing -y
eval `opam config env`
opam update
opam switch list-available
opam switch create 4.07.0
opam init -y
eval `opam config env`
After this Everything should be latest as of now.

Installing Ruby 2.3 on WSL (Windows Subsystem for Linux)

First off, sorry for my bad English.
I'm trying to install Ruby 2.3.0 on my system with rbenv via Windows Subsystem for Linux aka Ubuntu on Windows 10. I followed this instruction (but not 100% exactly). but every time I try, It fails to build Ruby with this log.
check struct members..
check libraries....
Use ActiveTcl libraries (if available).
Search tclConfig.sh and tkConfig.sh..............................
Fail to find [tclConfig.sh, tkConfig.sh]
Use X11 libraries (or use TK_XINCLUDES/TK_XLIBSW information on tkConfig.sh).
Warning:: cannot find X11 library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options. If your Tcl/Tk don't require X11, please try --without-X11.
Can't find X11 libraries.
So, can't make tcltklib.so which is required by Ruby/Tk.
Failed to configure tk. It will not be installed.
Failed to configure tk/tkutil. It will not be installed.
configuring zlib
make[1]: Entering directory `/tmp/ruby-build.20160522033606.7696/ruby-2.3.1'
make -C ext/digest/sha2 -w --jobserver-fds=6,7 -j V= realclean
make[2]: Entering directory `/tmp/ruby-build.20160522033606.7696/ruby-2.3.1/ext/digest/sha2'
Makefile:39: *** missing separator. Stop.
make[2]: Leaving directory `/tmp/ruby-build.20160522033606.7696/ruby-2.3.1/ext/digest/sha2'
make[1]: *** [ext/digest/sha2/realclean] Error 2
make[1]: Leaving directory `/tmp/ruby-build.20160522033606.7696/ruby-2.3.1'
make: *** [build-ext] Error 2
and this is my installed package list
libx11-data/trusty,now 2:1.6.2-1ubuntu2 all [installed]
libx11-dev/trusty,now 2:1.6.2-1ubuntu2 amd64 [installed]
libx11-doc/trusty,now 2:1.6.2-1ubuntu2 all [installed,automatic]
libx11-xcb1/trusty,now 2:1.6.2-1ubuntu2 amd64 [installed,automatic]
libtk8.4/trusty,now 8.4.20-7 amd64 [installed,automatic]
libtcl8.4/trusty,now 8.4.20-7 amd64 [installed,automatic]
As you see, I installed X11, tcl, tk but my system can't detect them.
Have I done wrong? or it is just a bug?
Any help would be appreciated. Thank you for reading.
My installation follow this tutorial, go there for most recent update: link here.
1. Install Ruby
First some dependencies for Ruby:
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev
Now for Ruby: there are 3 ways to install, each way conflict with each other, so choose one you think fit yours most or my suggestion: rbenv
Using rbenv (recommend)
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.3.1
rbenv global 2.3.1
ruby -v
Using rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.3.1
rvm use 2.3.1 --default
ruby -v
From the source
cd
wget http://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
tar -xzvf ruby-2.3.1.tar.gz
cd ruby-2.3.1/
./configure
make
sudo make install
ruby -v
After install Ruby, install Bundler
gem install bundler
2. Install Rails
First you need NodeJS:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Then install rails:
gem install rails -v 4.2.6
If you're using rbenv, you'll need to run the following command to make the rails executable available:
rbenv rehash
Now that you've installed Rails, you can run the rails -v command to make sure you have everything installed correctly:
rails -v
# Rails 4.2.6
3. Install DB
MySQL:
You can install MySQL server and client from the packages in the Ubuntu repository. As part of the installation process, you'll set the password for the root user. This information will go into your Rails app's database.yml file in the future.
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
PostgreSQL:
Currently, some bug prevents you from installing Postgres correctly, so I recommend you MySQL for now.
sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-common
sudo apt-get install postgresql-9.5 libpq-dev
The Postgres installation doesn't setup a user for you, so you'll need to follow these steps to create a user with permission to create databases. Feel free to replace chris with your username.
sudo -u postgres createuser chris -s
# If you would like to set a password for the user, you can do the following
sudo -u postgres psql
postgres=# \password chris
Final Steps
Now make sure things go right not left
#### If you want to use SQLite (not recommended)
rails new myapp
#### If you want to use MySQL
rails new myapp -d mysql
#### If you want to use Postgres
# Note that this will expect a postgres user with the same username
# as your app, you may need to edit config/database.yml to match the
# user you created earlier
rails new myapp -d postgresql
# Move into the application directory
cd myapp
# If you setup MySQL or Postgres with a username/password, modify the
# config/database.yml file to contain the username/password that you specified
# Create the database
rake db:create
rails server
Make sure you have updated your Windows installation - run 'Windows 10 Upgrade Assistant' and install the Windows 10 Creators Update. Anything before this is riddled with bugs and my rbenv Rails install wouldn't work. If it still won't work after updating Windows to CU then you can always just use rvm instead. You may need to reinstall everything anyway, as its recommended to reinstall/upgrade Ubuntu if you are using WSL.

Trouble installing m2crypto with pip on OS X / macOS

pip install m2crypto
Generates the following output:
building 'M2Crypto.__m2crypto' extension
swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
swig -python -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
SWIG/_m2crypto.i:30: Error: Unable to find 'openssl/opensslv.h'
SWIG/_m2crypto.i:33: Error: Unable to find 'openssl/safestack.h'
SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h'
SWIG/_ec.i:7: Error: Unable to find 'openssl/opensslconf.h'
error: command 'swig' failed with exit status 1
I've run:
brew install swig
I wanted a nicer way without installing manually and using only Homebrew (which also does not link openssl by default). Also using pip was a requirement. This seems to work with newest m2crypto 0.22.5. I also tested it once with m2crypto 0.22.3 and seems also to work. The OpenSSL version here is 1.0.2d:
brew install openssl
brew install swig
Finally install m2crypto on macOS in your Bash. It is a long command but it changes SWIG and clang environment variables only during pip install so that m2crypto will get all OpenSSL requirements:
env LDFLAGS="-L$(brew --prefix openssl)/lib" \
CFLAGS="-I$(brew --prefix openssl)/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I$(brew --prefix openssl)/include" \
pip install m2crypto
btw. the last command also works if you use e.g. a requirements.txt.
Update:
Additional also the command for fish shell users...
env LDFLAGS="-L"(brew --prefix openssl)"/lib" \
CFLAGS="-I"(brew --prefix openssl)"/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I"(brew --prefix openssl)"/include" \
pip install m2crypto
thanks to therealmarv env flags i was able to get this to work with the macports version of openssl/swig, this is what i did:
sudo port install openssl
sudo port install swig
sudo port install swig-python
then use therealmarv lines but replace "$(brew --prefix openssl)" with the dir from macports which should be "/opt/local"
sudo env LDFLAGS="-L/opt/local/lib" \
CFLAGS="-I/opt/local/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I/opt/local/include" \
pip install M2Crypto
I just went through a lot of pain getting this working in El Capitan. Here is what I had to do:
Install OpenSSL (you have to use an older version, m2crypto will not compile otherwise)
curl -O https://www.openssl.org/source/openssl-0.9.8zg.tar.gz
tar -xvzf openssl-0.9.8zg.tar.gz
cd openssl-0.9.8zg
./Configure --prefix=/usr/local darwin64-x86_64-cc
make && make test
sudo make install
Install m2crypto
git clone https://github.com/martinpaljak/M2Crypto.git
cd M2Crypto
python setup.py build build_ext --openssl=/usr/local
sudo python setup.py install build_ext --openssl=/usr/local
AFAIK it is installed... I still have to do some testing though.
Got exact same issue on Ubuntu 18.04 LTS, while trying to execute
pip install M2Crypto==0.24.0
Did the following to get rid of it:
sudo apt-get install swig
sudo apt-get install libssl1.0-dev
This fixed my problem (Python 2.7):
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages
macos v10.15.6
m2crypto v0.35.6
pip v20
Solution by therealmarv works,
If the program does not take effect, you can try to upgrade your brew packages. Before the solution.
brew update # update homebrew self
brew upgrade # upgrade all
sudo apt-get install python-m2crypto

Problems Installing Metasploit Framework on Ubuntu

I have encountered 3 problems while following this guide to installing Metasploit Framework on Ubuntu and Debian:
1) After installing proper version of ruby, there is a command given for installing Ruby libraries: sudo gem install bundler. When I typed that in and hit enter, it says "command not found". After some researching on the internet, I decided to remove sudo and try again. So I've entered gem install bundler and it worked fine. Will this cause any problems?
2) After installing Metasploit Framework, there is a command given to install the required gems and versions:
cd metasploit-framework
bundle install
But when I tried that, I got this error:
rbenv: version '2.1.6' is not installed
I really don't know what to do next (But I moved on).
3) Probably due to the previous problems, in the end when I executed msfconsole command, it said
could not find rake-10.4.2 in any of the sources.
run bundle install to install the missing gems
But the bundle install doesn't help either, because when I run that it says
Could not locate Gemfile or .bundle/directory
Any help would be appreciated.
EDIT: When I asked the person himself who had written the guide, regarding this, he told me to select the version of ruby I had just installed with either rebind or RVM before installing bundler, and then to run the bundle install. Could you please list the commands to do so? I am really new to Linux!
step 1 :
sudo apt-get update
sudo apt-get upgrade
step 2 :
Install dependent packages
sudo apt-get install build-essential libreadline-dev libssl-dev libpq5 libpq-dev libreadline5 libsqlite3-dev libpcap-dev openjdk-7-jre git-core autoconf postgresql pgadmin3 curl zlib1g-dev libxml2-dev libxslt1-dev vncviewer libyaml-dev curl zlib1g-dev
step 3 :
Install Ruby
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
source ~/.bashrc
rvm install 2.1.6
rvm use 2.1.6 --default
ruby -v
step 4 :
Install and configure postgresql
sudo apt-get install postgresql
sudo -s
su postgres
createuser msf -P -S -R -D
createdb -O msf msf
exit
Step 5 :
Install Metasploit Framework
cd /opt
sudo git clone https://github.com/rapid7/metasploit-framework.git
sudo chown -R `whoami` /opt/metasploit-framework
cd metasploit-framework
cd metasploit-framework
sudo bash -c 'for MSF in $(ls msf*); do ln -s /opt/metasploit-framework/$MSF /usr/local/bin/$MSF;done'
Still if you are facing any issue, you can download the iso or vm image from kali wesbite
I have this problem in kali after install metasploit-framework, and i can't run msfconsole. I solved the problem using the following method:
At change your directory to /usr/share/metasploit-framework:
cd /usr/share/metasploit-framework
and after that, install bundler with gem:
gem install bundler
then:
bundle install
at the end you need to update:
gem update --system
and it will work!
This command fixes it:
apt-get install ruby2.1-dev &&\
apt-get install libsqlite3-dev &&\
bundle install
What it does: install ruby development items

Resources