Could not open ...Builds/CodeBlocksLinux/resources.rc 'undefined reference to gtk_init '

I am trying to build the AudioAppDemo using Codeblocks, so I loaded the generated cbp file into codeblocks. I get the above error…
I also get 'undefined reference to gtk_init ', but I think that is related…

I solved the 'could not open ’ problem, by adding *.rc files to the extension handler.
The remaining problem is 'undefined reference to gtk_init '…

1 Like

Does the “undefined reference” error contain any more information, such as where the reference is used?

As far as I can tell, JUCE doesn’t directly call any function named gtk_init, although it does attempt to dynamically load a function with that name. Which version of JUCE are you using? Does the error go away if you set JUCE_WEB_BROWSER=0 in the module configuration settings for juce_gui_extra?

I am on Juce 6.1.2. The error appears in /home/richard/JUCE/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp:167:
I will try your other suggestions in a moment…
I notice that juce_gui_extra is not even in the listed modules in the Projucer, (but it is present in the imported project under codeblocks - weird)

I tested this out just now. I’m running on Ubuntu 21.04. My steps:

  • Build and run the Projucer.
  • In the Projucer, select “File → Open Example → Audio → AudioAppDemo” from the menu. (I checked the module list at this point, and juce_gui_extra is included.)
  • Under “Exporters”, click the “+” button and add a “CodeBlocks (Linux)” exporter.
  • Select “File → Save Project” from the menu.
  • After saving, open the saved .cbp file from “Builds/CodeBlocksLinux”.
  • Hit “Build” (the cog icon) in the toolbar of CodeBlocks.

After running all of these steps, the project builds without problems on my system.

Which operating system are you running? The Linux CodeBlocks exporter is only tested on native Linux, so it’s not guaranteed to work on other platforms (e.g. Windows Subsystem for Linux). If you’re using Windows, you need to use the Windows CodeBlock exporter.

If the juce_gui_extra module is not included in your Projucer project, it sounds like something has gone wrong somewhere while loading/creating the project. I’d recommend checking that your Projucer is up-to-date (if you have multiple copies on your system, you should make sure you’re using a version built from the version of JUCE that you’re currently using). Then, follow the steps I listed above to create a new version of the AudioAppDemo project. If the new version of the project still doesn’t build properly, let me know and I’ll investigate further.

I have not built the Projucer again (yet). My version of the Projucer is 6.1.2, the same as Juce.
What is your version?

I did follow the steps and juce_gui_extra is included now in the project.
But the build step in codeblocks gives the same error about gtk_init.
I am running on Linux Mint 20 Ulyana …

BTW, I disabled the JUCE_WEB_BROWSER in the juce_gui_extra and now it compiles!
But the path for CodeBlocks (Linux) is wrong and red, but I cannot change that. But it works now…

Just tried building on Mint and still was not able to repro the issue.

Do you definitely have the gtk webkit package installed? i.e.

sudo apt install libwebkit2gtk-4.0-dev

I enabled the JUCE_WEB_BROWSER again and now it builds without problem.
Only the path for Code::Blocks(Linux) is wrong (and red). It is ../../juce, I think it should be:
~/JUCE/modules
But I cannot change that in the Projucer