"Failed to call `y()` to execute the macro" Error

Hi, I am quite new to the root and in general all concepts surrounding it. I installed it on Ubuntu manually ,including all dependencies. I can call and run root for basic things like 1+1 but when I use an text file and add my code in it, it won’t work.

Sample Code in the Text

void x()
{
 TH1F *hist = new TH1F("hist", "Histogram", 100, 0, 100);
 TCanvas *c1 = new TCanvas();
hist-> Draw();
}

Codes in the Console

source root/bin/thisroot.sh

mkdir x

cd x

gedit y.C

root y.C

Message I Get:

cling::DynamicLibraryManager::loadLibrary(): libtbb.so.12: cannot open shared object file: No such file or directory
root [0] 
Processing y.C...
warning: Failed to call `y()` to execute the macro.
Add this function or rename the macro. Falling back to `.L`.

I tried a simple hello world code directly on the console which worked but when I used same code in the text file (y) and try to run it by root in the console it didn’t work.

ROOT Version: 6.30.6
Platform: Ubuntu 22.04.04 LTS (Virtual Machine on Win11)
Compiler: -

If the function in the macro is called x, your macro file should also be named x, i.e. x.C