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


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

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

1. Install homebrew (refer to if not installed

2. Clone from GitHub Repository

git clone –recursive && 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

# 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


(Screenshot – end of source compile)

5. Run

bin/telegram-cli -k

(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.

Reference) (Official telegram-cli page) (solving libtool installation problem) (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 *