14

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?

Goncalo
  • 141

5 Answers5

12

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
muru
  • 207,228
labarna
  • 2,632
8

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.

0

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"
make

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)

Tushar
  • 139
0

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

TO INSTALL EXPECT YOU NEED TO REPLACE 100500 PACKAGES

SINCE UBUNTU WENT MAD LOL

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

EXPOSE 80

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.

0

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/