13

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?

3 Answers 3

11

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
2
  • 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
    Oct 27, 2013 at 20:41
  • also, it says i have the newest version of tcl8.5-dev
    – Goncalo
    Oct 27, 2013 at 20:42
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.

3
  • 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. 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
    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 :( Aug 23, 2021 at 14:45
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)

You must log in to answer this question.

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