Building NS-3 3.26 in Mac OS X 10.13 (High Sierra)

Standard

I haven’t updated the ns-3 installation guide for Mac OS X, so I updated with most recent version of Mac OS X 10.13 (High Sierra)

1. Get the source and unarchive

cd
mkdir workspace
cd workspace
wget http://www.nsnam.org/release/ns-allinone-3.26.tar.bz2
tar xjf ns-allinone-3.26.tar.bz2

2. Install required library (except goocanvas and pygoocanvas)

brew install libxml2
# if libxml2 is installed but still shows error on installing NS-3, 
# try 'brew upgrade libxml2' without quote

# install other required library (valgrind should be manually installed)
brew install gsl libgcrypt doxygen gtk cvs unrar p7zip xz cmake bzr 

brew install python python3
pip3 install meson
brew install graphviz pygtk

# install gccxml
git clone https://github.com/gccxml/gccxml.git
cd gccxml
mkdir gccxml-build
cd gccxml-build
cmake ../
make
sudo make install
cd ../..
rm -rf gccxml

# install required python library
pip2 install pygraphviz pygccxml

# install qt4 if you want to use netanim
# https://www.nsnam.org/wiki/Installation#Mac_OS_X, step 3
brew install cartr/qt4/qt-legacy-formula

# install mercurial if you want to use it
# https://www.nsnam.org/wiki/Installation#Mac_OS_X, step 4
brew install mercurial

# install valgrind by source
xcode-select --install

git clone git://sourceware.org/git/valgrind.git
cd valgrind

# Recent version is already patched to support High Sierra, so nothing to do 
./autogen.sh
./configure
make
sudo make install

valgrind --version # just for test
cd ..

3. Install goocanvas-0.14 (It is important to use 0.14, though more recent versions are available)

wget http://ftp.gnome.org/pub/gnome/sources/goocanvas/0.14/goocanvas-0.14.tar.gz
tar xvfz goocanvas-0.14.tar.gz
rm goocanvas-0.14.tar.gz

cd goocanvas-0.14
./configure
make
sudo make install
cd ..
rm -rf goocanvas-0.14

4. Install pygoocanvas-0.14.1 (tested with goocanvas 2.0.2 from homebrew)

wget https://launchpad.net/pygoocanvas/trunk/0.14.1/+download/pygoocanvas-0.14.1.tar.gz
tar xvfz pygoocanvas-0.14.1.tar.gz

cd pygoocanvas-0.14.1
wget http://study.prl85.com/wp-content/uploads/sites/2/2015/03/install-on-mac.sh
chmod 755 install-on-mac.sh

wget http://study.prl85.com/wp-content/uploads/sites/2/2015/03/pygoocanvas-0.14.1-mac.patch
patch < pygoocanvas-0.14.1-mac.patch
./install-on-mac.sh

cd ..
rm -rf pygoocanvas-0.14.1

5. Install ns-3

cd ns-allinone-3.26
python2 ./build.py --enable-examples --enable-tests

6. Test whether ns-3 is installed properly

cd ns-3.26
./test.py

7. Execute example file to check ns-3 is working or not

cp examples/tutorial/first.cc scratch/myfirst.cc
./waf
./waf --run scratch/myfirst

Reference)
https://www.nsnam.org/docs/release/3.26/tutorial/html/getting-started.html
https://www.nsnam.org/wiki/Installation#Mac_OS_X
https://stackoverflow.com/questions/39690404/brew-install-qt-does-not-work-on-macos-sierra
http://valgrind.org/downloads/repository.html
https://stackoverflow.com/questions/13421675/make-fails-while-installing-valgrind
https://github.com/mesonbuild/meson/issues/1054
https://mithunme.wordpress.com/2012/09/11/installing-ns-3-in-ubuntu

Appendix A)
In previous guide, the list of required library was following:

brew install wget mercurial bzr boost pkg-config gtk gsl doxygen graphviz cvs unrar p7zip xz cmake gtkmm gtkmm3 pygtk

If you have problem with installing, try installing package above.

Appendix B)
To test PyViz, see link https://www.nsnam.org/wiki/PyViz for the instruction.

iTunes (Mac/PC) and iOS built-in Podcast app are unable to process indirect download link (+Solution)

Standard

(Updated) Added solution for Nginx

Symptom)

If the audio/video URL of each item contains extension information, there is no problem.
(Example: http://prl85.com/podcast/example.mp3)

However, if the audio/video URL of each item has no information about file extension, then problem occurs. (Especially if you are using download handler instead of directly downloading file)
(Example: http://prl85.com/somehandler?episode=1)

In latter case, built-in Podcast app only can play episodes by streaming, not from downloaded file.
(After downloading episode, you can’t play that episode unless you delete the downloaded file)

Other podcast apps (Downcast, Podcruncher, …) has no problem with this (playing episodes from downloaded files).

Solution)
1. Apple fixes built-in Podcast app
(but…. when? btw, Mac/WIndows iTunes also have same problem)

2. Use direct link (http://prl85.com/example.mp3, instead of http://prl85.com/somehandler?episode=1) for media link
(but, what if it is inevitable to use download handler link?)
(it could be inevitable to use download handler link when you store the audio/video in cloud storage like dropbox, onedrive, google drive, …)

3. If solution 2 is unavailable, use redirection script (in my case, by PHP)
(http://prl85.com/redirect.mp3?episode=1 -> equivalent to http://prl85.com/somehandler?episode=1, downloads episode 1 file)

the extension of handler file should be that of media file (.mp3, .m4a, …), depending on your original media type.
(For solution 3, requires registering .mp3 or .m4a as being handled by PHP handler – recommends .htaccess in Apache case)

Example of redirection script (redirection.mp3)

<?php header('Content-Type: audio/mp3'); header('Location: http://prl85.com/somehandler?episode=1'); ?>


Example of .htaccess (For apache webserver; put this file with same directory of redirection script)

AddHandler application/x-httpd-php .mp3

Example of nginx.conf (For Nginx webserver; might be complex than Apache case because it requires modification of setting file)

server {
­	location /podcast_service/ { # where the redirection script exists
		location ~ .*\.mp3|.*\.m4a$ { # extensions you want to handle
			fastcgi_pass 127.0.0.1:9000;
			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
			include fastcgi_params;
			fastcgi_read_timeout 180;
		}
	}
}

Compiling telegram-cli on Mac OSX 10.13 (with homebrew)

Standard

Test environment) Mac OSX 10.13 (High Sierra) with homebrew
(I prefer homebrew as it doesn’t require superuser permission, compared to macports)

Changes)
The way installing required packages (step 3) and compiling package (step 4) are updated in the official page, so I reflected the changes.

Procedure)
1. Install homebrew (refer to http://brew.sh) if not installed

2. Clone from GitHub Repository

git clone –recursive https://github.com/vysheng/tg.git && cd tg

3. Install required packages (bison requires to be installed in homebrew for solving problem installing libevent)

brew install bison
export PATH=”/usr/local/opt/bison/bin:$PATH”
# to use installed bison permanently
echo ‘export PATH=”/usr/local/opt/bison/bin:$PATH”‘ >> ~/.bash_profile

brew install libconfig readline lua python libevent jansson

4. Compile telegram-cli
(7.0.3_1, the version of readline, can be changed according to update; change it to match your installed version)

# edit lua-tg.c to comment line 664~666 (get_peer())

export CFLAGS=”-I/usr/local/include -I/usr/local/Cellar/readline/7.0.3_1/include -I/usr/local/Cellar/openssl/1.0.2l/include
export LDFLAGS=”-L/usr/local/lib -L/usr/local/Cellar/readline/7.0.3_1/lib -L/usr/local/Cellar/openssl/1.0.2l/lib
./configure

# before executing make, edit Makefile and remove -I/usr/local/include in CFLAGS (line 3 in my case)

# (before edit)
# CFLAGS=-I/usr/local/include -I/usr/local/Cellar/readline/7.0.3_1/include – I/usr/local/Cellar/openssl/1.0.2l/include
# (after edit)
# CFLAGS=-I/usr/local/Cellar/readline/7.0.3_1/include -I/usr/local/Cellar/openssl/1.0.2l/include

make

(Screenshot – end of source compile)

5. Run

bin/telegram-cli -k tg-server.pub

(You need to config the client by entering phone number including country code and code – one-time setting)

(Screenshot – successful configuration, you can see online notification)

cf) When you see “CONFIGURE: ERROR: CANNOT RUN C COMPILED PROGRAMS.” error when trying to install packages, execute xcode-select –install in terminal to (re)install Xcode command line development tools.
https://study.prl85.com/resolving-configure-error-cannot-run-c-compiled-programs-error-when-using-home-brew/

Reference) 
https://github.com/vysheng/tg (Official telegram-cli page)
https://stackoverflow.com/questions/44187405/issues-building-doxygen-with-cmake (solving libtool installation problem)
https://github.com/vysheng/tg/issues/996 (solving lua-tg.c compile problem)

Resolving “configure: error: cannot run C compiled programs.” error when using home-brew

Standard

Symptom)
You might see “configure: error: cannot run C compiled programs.” error when trying to install some package using homebrew.

(Example)
Screen Shot 2015-06-12 at 11.00.07 PM

Solution)
It happened to me when upgraded to a new major release of Mac OSX. (e.g. from 10.10 to 10.11)
Open terminal, execute following command, and install Xcode command line development tools.

xcode-select –install

After installation, homebrew will work as expected.

즉, xcode command line develop tool을 재설치해서 해결한다는 의미입니다.

Reference)
http://stackoverflow.com/questions/19594719/install-any-version-of-ruby-with-rvm-on-mavericks