I'm trying to install something using the 'make' command, however it gives me the fatal error:tcl.h no such file or directory. I'm new to linux, can anyone help me?

5 Answers 5


This means you're missing the tcl development files. The easiest way to check is to go to: http://packages.ubuntu.com/ and put "tcl.h" in the "search contents of packages" field. If you do this you'll find that tcl.h can be found in a number of packages you'll want to install one of those:

sudo apt-get install tcl8.6-dev
  • when i use sudo apt-get install tcl8.6-dev, it says: E:Unable to locate package tcl8.6-dev E:Couldn't find any package by regex 'tcl8.6-dev'
    – Goncalo
    Commented Oct 27, 2013 at 20:41
  • also, it says i have the newest version of tcl8.5-dev
    – Goncalo
    Commented Oct 27, 2013 at 20:42

Once you have a Tcl dev package installed, you'll then possibly come across the code expecting tcl.h to be in /usr/include/, but in order to facilitate multiple versions of Tcl being installed, Ubuntu places tcl.h in /usr/include/tcl/ - note the extra directory level.

Replacing: #include <tcl.h> with #include <tcl/tcl.h> in the source code you're trying to build should get around this.

  • 3
    Instead of changing the code, you can change the include path of the compiler: add the option "-I/usr/include/tcl" to the compilation. Commented May 12, 2020 at 7:06
  • Don't change the code or the compiler flags! Why don't you just install tcl-dev package? This one is immediately found as it placs headers in /usr/include. :)
    – 71GA
    Commented Aug 19, 2021 at 11:57
  • 1
    @71GA That may have changed since 20.04 a.k.a Focal (which is what's running on the box I've just check on), but tcl-dev on 20.04 placed tcl.h in /usr/include/tcl. If it had done as you say, I'd not've made my original comment :) 20.04 creates a symlink: ❯ ls -l /usr/include/tcl{,.h} ls: cannot access '/usr/include/tcl.h': No such file or directory lrwxrwxrwx 1 root root 6 Feb 23 2019 /usr/include/tcl -> tcl8.6 Gah, no formatting in comments :( Commented Aug 23, 2021 at 14:45

Happened to me, when trying to manually install python3.9 and fixing tinker import error Error:ModuleNotFoundError: No module named '_tkinter'

Then, i came to know, when you try to manually configure, you have to pass additional arguments.

./configure --with-tcltk-includes="-I/Library/Frameworks/Tcl.framework/Headers -I/Library/Frameworks/Tk.framework/Headers" --with-tcltk-libs="/Library/Frameworks/Tcl.framework/Tcl /Library/Frameworks/Tk.framework/Tk"

As, labarna mentioned you can search on ubuntu packages and install those. Then after that while downloading correct package, it still gave another another.

gcc -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -DWITH_APPINIT=1 -I./Include -I. -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/root/fix/Python-3.9.11/Include -I/root/fix/Python-3.9.11 -c /root/fix/Python-3.9.11/Modules/_tkinter.c -o build/temp.linux-x86_64-3.9/root/fix/Python-3.9.11/Modules/_tkinter.o -I/Library/Frameworks/Tcl.framework/Headers -I/Library/Frameworks/Tk.framework/Headers /root/fix/Python-3.9.11/Modules/_tkinter.c:46:10: fatal error: tk.h: No such file or directory 46 | #include <tk.h> | ^~~~~~

As, you can see its expecting package under /usr/local/include. And, your download file might be installed to some other location. You have to either copy the required file or create symlink(softlink) to correct directory (for me it was /usr/local/include)


All of the previous answers do not work for docker images, e.g. for ubuntu, php. Here is the solution:

from php:7.3.30-apache-bullseye
RUN apt-get update && apt-get install -qq tcl tcl-dev tk tk-dev
RUN apt-get install -qq expect expect-dev git

WORKDIR /usr/include
RUN git clone https://github.com/christophchamp/expect.git expect_builder && \
    cp -r expect_builder/* . && \
    cp -r tcl/* .

WORKDIR /usr/include/expect_builder
# replace with ./configure --build=x86_64-unknown-linux-gnu for x86 #
RUN ./configure --build=aarch64-unknown-linux-gnu && \
    make && \
    cp libexpect5.45.1.so /usr/lib/libexpect.so && \
    cp expect /usr/lib/expect

RUN pecl install expect
RUN echo "extension=expect" >> "$PHP_INI_DIR/php.ini-production" && \
    mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

WORKDIR /var/www/html
COPY src/ /var/www/html/

# export ports #

# update flag #
RUN echo 'user_flag:FLAG{...}' >> /etc/passwd

# change user #
USER www-data

The problem

debian and ubuntu does not install tcl into the usr/include location, instead, it is installed inside usr/include/tcl. To resolve this issue, you may copy all of the files to the usr/include. But it will solve only the first part of the problem since apt-get install expect does not install any header files. To solve this part of the issue, I found the following repo which is basically fork of old expect source. You can clone it, unpack and configure / make. After that you have to place it into the proper location.


For me I just copied all the files under /usr/include/tcl/ to /usr/include/ and it worked for me, you should able to see tcl.h file in /usr/include/

sudo cp -r /usr/include/tcl/* /usr/include/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .