How do I link C code against BoringSSL? - linux

I want to install BoringSSL and link against BoringSSL instead of OpenSSL on Ubuntu.
I couldn't find a simply tutorial of how to do this, the building instructions here are vague.

1) Install the language go, if not already done. https://golang.org/doc/install?download=go1.8.1.linux-amd64.tar.gz
Example :
cd /usr/local/
sudo tar xvf [path-to]/go1.8.1.linux-amd64.tar.gz
cd bin/
sudo ln -s ../go/bin/go* ./
2) boringssl, please read README.md, BUILDING.md ...
cd boringssl/
mkdir build
cd build/
cmake ../
make
There is no 'make install'. You will have to find libssl.a (in build/ssl/) etc. etc., and point to -lssl when using. ( Unfortunately you may already have like /usr/lib/libssl.so, which will be linked to, if first in the LD_LIBRARY_PATH ).

Related

RPM build issues

I have an RPM spec file like this, I have compiled a C file and created an executable and trying to copy it to buildroot/tmp folder and trying to execute it from there,
%install
mkdir -p %{buildroot}/tmp/
install -m 755 /root/Desktop/np %{buildroot}/tmp/np
./%{buildroot}/tmp/np
%files
/tmp/np
When I try to build the RPM, I am facing an error
"/var/tmp/rpm-tmp.0HMeZn: line 35:
.//root/rpmbuild/BUILDROOT/hp-simulate-generalfailure1-1.0.0-1.x86_64/tmp/np:
No such file or directory"
Help me out to make a clean build. Thanks in advance.
Let's put aside that you are doing something very strange and executing rpmbuild as root (very nasty).
The %{buildroot} is an absolute path. See:
$ rpm --eval '%{buildroot}'
/home/msuchy/rpmbuild/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64
If you are really trying to execute that binary, you should not put the leading ./ there. So you snippet should be:
%install
mkdir -p %{buildroot}/tmp/
install -m 755 /root/Desktop/np %{buildroot}/tmp/np
%{buildroot}/tmp/np
%files
/tmp/np
Running anything in %install section will occur only on the build machine, during rpm build process. It will not happen when you install the RPM.
To run something upon package installation, you have to make use of scriplets:
%install
mkdir -p %{buildroot}/tmp/
install -m 755 /root/Desktop/np %{buildroot}/tmp/np
%files
/tmp/np
%post
/tmp/np
In example above, /tmp/np will be executed when package is either installed for the first time, or upgraded.

nodejs/bin/node does't exists when truing to install node.js on server

I have shaed hosting on siteground , basically my server runs PHP , but i also wanted to run node on my server , so i ssh'ed using putty and ran the following commands:
curl http:// nodejs.org/dist/latest/node-v8.11.3-linux-x64.tar.xz Then unzipped it.
mv node-v8.11.3-linux-x64/ nodejs.
mkdir ~/bin
cp nodejs/bin/node ~/bin
The last command throws an error
cp: connot stat nodejs/bin/node: no such file or directory exists
I was basically trying to follow the tutorial on HERE.
Follow this guide instead, it's from the actual node GitHub instead of a Medium article: How to install Node.js via binary archive on Linux?.
You are going to need 3 specific programs:
curl to download stuff
tar to deal with tar files
xz to deal with zip compression
Make sure all of those are installed using (and this assumes you're using Ubuntu or a distro that leverages apt):
sudo apt-get update && sudo apt-get install -y curl tar xz-utils
After that do something a little bit different from the tutorial
Download and save the archive:
curl -O https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.xz
Untar the archive:
tar xf node-v8.11.3-linux-x64.tar.xz
Make a nodejs directory to organize your versions:
mkdir /usr/local/lib/nodejs
Move the unarchived folder to your /usr/local/lib/nodejs folder:
mv node-v8.11.3-linux-x64 /usr/local/lib/nodejs/
Symlink node and npm into the /usr/bin/ folder:
ln -s /usr/local/lib/nodejs/node-v8.11.3-linux-x64/bin/node /usr/bin/node
ln -s /usr/local/lib/nodejs/node-v8.11.3-linux-x64/bin/npm /usr/bin/npm
Make sure everything is working:
node -v
npm -v

How to uninstall libc++ after installing from source?

I installed libc++ from source using following script. The make uninstall is not supported. What would be the best way to uninstall it?
git clone --depth=1 https://github.com/llvm-mirror/llvm.git llvm-source
git clone --depth=1 https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx
git clone --depth=1 https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi
export C_COMPILER=clang
export COMPILER=clang++
# Build and install libc++
mkdir llvm-build && cd llvm-build
cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr \
../llvm-source
make cxx
sudo make install-cxxabi install-cxx
Well, after lot of searching, it is clear that there is no automatic or even semi-automatic way to uninstall when make unintsall is not implemented. There are two ways to get around this:
If using cmake then run the install again but set the flag like -DCMAKE_INSTALL_PREFIX=./output. This will cause cmake to put all files in ./output. Now you can observe the files, and manually delete them. I think by default cmake would put these files at /usr/local.
Another cool trick you can use if install_manifest.txt file is generated: cat install_manifest.txt | xargs echo sudo rm | sh.

installing systemc on ubuntu

I am a beginner.
I'm installing systemc231 on Ubuntu and I have done this:
tar -xzvf systemc-2.3.1.tgz
cd systemc-2.3.1
sudo mkdir /usr/local/systemc231
mkdir objdir
cd objdir
export cxx="<compiler>"
export cxx=g++
export cxx=clang++
setevn cxx g++
It answered :command not found
Then I continued:
../configure
It took a moment and checked something but finally it answered :
Configure:error: in /home/Ubuntu/systemc-2.3.1/objdir':
Configure:error:c++compiler cannot create executables see 'config.log' for more details
And then I continued :
make
And it answered :
make:*** no targets specified no makefile found. Stop.
Now what can l do?
This is the link of systemc231 file and I have used its readme and install files for writing the commands :
http://accellera.org/images/downloads/standards/systemc/systemc-2.3.1.tgz
In Ubuntu, you use export to set environmental variables. In other Linux distributions, you use setenv. You only need one of those commands. do a command to figure out if g++ is installed
which g++
If it doesnt return something like
/usr/bin/g++
Then its not installed, just install it with
sudo apt-get install build-essential
then check again with which
You created an installation directory /usr/local/systemc231 you need to specify that you want to install systemc therein in the configure command. Find a tutorial about setting up systemc and eclipse configuration in ubuntu on my blog

Install TCL/TK without root

I'm trying to install TCL/TK as a regular user on RedHat 5:
TCL_VERSION=8.6.1
BASE_PATH=/myownpath
tar -xzf tcl${TCL_VERSION}-src.tar.gz
cd tcl${TCL_VERSION}/unix
./configure \
--prefix=${BASE_PATH} \
--without-tzdata \
--enable-64bit
make -j9
sed -e "s#^\(TCL_SRC_DIR='\).*#\1${BASE_PATH}'#" \
-e "/TCL_B/s#='\(-L\)\?.*unix#='\1${BASE_PATH}/lib#" \
-i tclConfig.sh
make install
make install-private-headers
chmod -v 755 ${BASE_PATH}/lib/libtcl*.so
So far so good: ${BASE_PATH}/include/tcl.h exists and ${BASE_PATH}/lib/tclConfig.sh looks fine:
# String to pass to the compiler so that an extension can
# find installed Tcl headers.
TCL_INCLUDE_SPEC='-I/myownpath/include'
Then I try installing TK:
tar -xzf tk${TCL_VERSION}-src.tar.gz
cd tk${TCL_VERSION}/unix
./configure \
--prefix=${BASE_PATH} \
--enable-64bit \
--with-tcl=${BASE_PATH}/lib \
make -j9
sed -e "s#^\(TK_SRC_DIR='\).*#\1${BASE_PATH}'#" \
-e "/TK_B/s#='\(-L\)\?.*unix#='\1${BASE_PATH}/lib#" \
-i tkConfig.sh
make install
make install-private-headers
chmod -v 755 ${BASE_PATH}/lib/libtk*.so
It fails at make with the following message:
tk8.6.1/unix/../generic/tk.h:19:17: error: tcl.h: No such file or directory
What did I miss?!?
I followed below steps to install tcl, tk on Linux(Ubuntu).
please use sudo to avoid any permission related issue
Create directory of your choice say /opt/tcltk
install tcl
Create dir /opt/tcltk
Download tcl8.6.9-src.tar.gz, tk8.6.9.1-src.tar.gz from (http://www.tcl.tk/software/tcltk/download.html)
Move above these two tar files in opt/tcltk/
cd /opt/tcltk/ to install tcl8.6.9
/opt/tcltk> sudo gunzip -c tcl8.6.9-src.tar.gz | tar -xf -
cd /opt/tcltk/tcl8.6.9/unix/
/opt/tcltk/tcl8.6.9/unix> sudo ./configure --prefix=/opt/tcltk
/opt/tcltk/tcl8.6.9/unix> sudo make
Optional you can check make by executing “sudo make test”
/opt/tcltk/tcl8.6.9/unix> sudo make install
verify installation by executing "/opt/tcltk/bin/tclsh8.6" on cli
Install tk
cd /opt/tcltk/ to Extract tk tar
/opt/tcltk/>sudo gunzip -c tk8.6.9.1-src.tar.gz | tar -xf -
/opt/tcltk/tk8.6.9/unix>sudo ./configure --prefix=/opt/tcltk
/opt/degrib/tcltk/tk8.6.9/unix>sudo make
sudo make install
Please fell free to comments if there is any issue while installation
If you're wanting to install Tcl as a normal user, it's easy to do so starting with the source distribution (you'll need to pick the version you want; I recommend 8.6.1 in general right now, but that's a recommendation that's bound to change over time).
Then, change to the unix directory inside the unpacked source distribution and run ./configure; IMPORTANT: to install as non-root you must specify the --prefix option to configure to say where it is going to be installed, and you have to specify it as a full path. For example, if I was to install it beneath my home directory, I'd use:
./configure --prefix=/home/dkf
Then, just do make and make install. Or combine into one as make all install; if you're not installing as a different user, you can do it as one step. After this, I'll find I can run Tcl 8.6.1 by doing /home/dkf/bin/tclsh8.6 and the binary library and tclConfig.sh will be in /home/dkf/lib; adjust in the obvious way for the path you specify. If you do not specify the --prefix, the source distribution uses /usr/local as a default, but that's a directory which is only normally writable by the root user.
The reason you have to specify the path like this is that the path to Tcl's support scripts is baked into the binary library. (It's runtime overridable, but I don't recommend doing that when you can easily just get things right to start out with.)
When building Tk, you need a sibling Tcl build. Currently, you're recommended to have them be the same version too. You should also specify --with-tcl= and give the path to the tclConfig.sh that you just installed; while it might work without, it's easiest to just do it this way. Once you've built and installed Tcl and Tk, you (probably) don't need to keep the source trees around.
OK, I admit that I do keep them around, but I'm a data packrat…

Resources