GCC -fpic option

-fpic

Generate position-independent code (PIC) suitable for use in a shared library, if supported for the target machine. Such code accesses all constant addresses through a global offset table (GOT). The dynamic loader resolves the GOT entries when the program starts (the dynamic loader is not part of GCC; it is part of the operating system). If the GOT size for the linked executable exceeds a machine-specific maximum size, you get an error message from the linker indicating that -fpic does not work; in that case, recompile with -fPIC instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k on the m68k and RS/6000. The x86 has no such limit.)

Position-independent code requires special support, and therefore works only on certain machines. For the x86, GCC supports PIC for System V but not for the Sun 386i. Code generated for the IBM RS/6000 is always position-independent.

When this flag is set, the macros __pic__ and __PIC__ are defined to 1.

from Wikipedia :

In computing, position-independent code (PIC) or position-independent executable (PIE) is a body of machine code that, being placed somewhere in the primary memory, executes properly regardless of its absolute address. PIC is commonly used for shared libraries, so that the same library code can be loaded in a location in each program address space where it will not overlap any other uses of memory (for example, other shared libraries)

Example :

swig -python hello.i
gcc -fpic -c hellomodule.c hello_wrap.c -I/usr/include/python3.4/
gcc -shared hellomodule.o hello_wrap.o -o _hello.so

References :

https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html https://en.wikipedia.org/wiki/Position-independent_code

GCC -shared option

-shared
Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options used for compilation (-fpic, -fPIC, or model suboptions) when you specify this linker option.

Example :

gcc -fpic -c hellomodule.c hello_wrap.c -I/usr/include/python3.4/
gcc -shared hellomodule.o hello_wrap.o -o _hello.so

Reference :

https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html

Install WordPress on Ubuntu

Install Apache

sudo apt-get install apache2

Install MySQL

sudo apt-get install mysql-server php5-mysql

Install PHP

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-curl
sudo apt-get install php5-cli

Create a MySQL Database and User for WordPress

mysql -u root -p
create database wordpressdb;
create user wordpressuser@localhost identified by 'pass1234';
grant all privileges on wordpressdb.* to wordpressuser@localhost;
FLUSH PRIVILEGES;

exit

Download WordPress

wget http://wordpress.org/latest.tar.gz

or

sudo apt-get install wordpress
sudo apt-get install php5-gd libssh2-php

The group ownership we will give to our web server process, which is www-data. This will allow Apache to interact with the content as necessary.

sudo chown -R :www-data /var/www/html/wordpress

MySQL Error: : ‘Access denied for user ‘root’@’localhost’

  1. Open & Edit /etc/my.cnf or /etc/mysql/my.cnf, depending on your distro.
  2. Add skip-grant-tables under [mysqld]
  3. Restart Mysql
  4. You should be able to login to mysql now using the below command mysql -u root -p
  5. Run mysql> flush privileges;
  6. Set new password by ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
  7. Go back to /etc/my.cnf and remove/comment skip-grant-tables
  8. Restart Mysql
  9. Now you will be able to login with the new password mysql -u root -p

Refernces :

https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04
https://kyup.com/tutorials/install-wordpress/
https://help.ubuntu.com/community/WordPress
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-16-04
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04
https://stackoverflow.com/questions/41645309/mysql-error-access-denied-for-user-rootlocalhost

GCC -o file option

-o file

Place output in file file. This applies to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.

If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.

Example :

gcc -shared hellomodule.o hello_wrap.o -o _hello.so

References :

https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html

Swappiness

– Open a terminal
– type in or copy/paste:

sudo gedit /etc/sysctl.conf

– a file will be opened
– add the following line at the bottom of that file:

# Swappiness
vm.swappiness = 10
vm.vfs_cache_pressure = 50

– save the file and close it.

After rebooting the swappiness is set to 10. This can be checked by running the following command in a terminal:

sudo cat /proc/sys/vm/swappiness

References :

https://sites.google.com/site/tipsandtricksforubuntu/system-tips/swappiness
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

Install Oracel Java on Linux

/usr/local/java/jdk1.8.0_66
sudo gedit /etc/profile
JAVA_HOME=/usr/local/java/jdk1.8.0_66
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_66/jre/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_66/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_66/bin/javaws" 1
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_66/jre/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_66/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_66/bin/javaws
. /etc/profile

References :

http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux