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)

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

    • GrapeFruitHolic

      I couldn’t maintain the blog for awhile, sorry for late reply.
      The good news is that I updated the post with testing on Mac OS X 10.13 (High Sierra), the most recent version!

Leave a Reply

Your email address will not be published. Required fields are marked *