failure to compile imgui glfw opengl on linux with gcc 11 2

0 votes

I've recently started coding with c++ and the project that im currently on requires imgui. so i set up the .h and .cpp libraries in a folder called "include" in the same folder as the source code. I'm currently trying to run the CPP in https://github.com/ocornut/imgui/tree/master/examples/example_glfw_opengl3 and compile it with GCC using GCC imgui.cpp -lstdc++ -lglfw -lGL -limgui but i just get

/usr/bin/ld: cannot find -limgui collect2: error: ld returned 1 exit status

yes I know there is a make file in the link but I'm using the file in another folder.

Apr 14, 2022 in Linux Administration by Aditya
• 7,680 points
1,097 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Assuming you downloaded imgui to a place called $IMGUI_DIR and the file that contains your main function is main.cpp, your compile command line should look like the following: (Also note that the \ are just there to break up the command)

g++ main.cpp -o main \ $IMGUI_DIR/imgui*.cpp $IMGUI_DIR/backends/imgui_impl_glfw.cpp $IMGUI_DIR/backends/imgui_impl_opengl3.cpp \ -I $IMGUI_DIR -I $IMGUI_DIR/backends \ -lglfw -lGL

In order, you tell the compiler:

  • Where your code is and where to put the output

  • What Imgui code to include, namely the core library and the two backends you want to use

  • Where Imgui code should look for its headers

If all this sounds like a lot, know that you can simply build the example you linked and override IMGUI_DIR at compile time with make IMGUI_DIR=/path/to/imgui

answered Apr 20, 2022 by Soham
• 9,710 points

edited Mar 5

Related Questions In Linux Administration

0 votes
0 answers

How to compile for Windows on Linux with gcc/g++?

I have written some effects in C++ ...READ MORE

Apr 13, 2022 in Linux Administration by Rahul
• 9,680 points
852 views
0 votes
1 answer

How to compile executable for Windows with GCC with Linux Subsystem?

Linux Subsystem fills in as a Linux-PC. ...READ MORE

answered Jun 20, 2022 in Linux Administration by Rahul
• 3,380 points
5,591 views
0 votes
0 answers

Get Selenium to work with Brave browser on Linux

I am trying to get Selenium to ...READ MORE

Apr 14, 2022 in Linux Administration by Soham
• 9,710 points
1,683 views
0 votes
1 answer

How to find the group associated with a user in linux?

To list all the groups groups or to list ...READ MORE

answered Jun 21, 2019 in Linux Administration by DareDev
• 6,890 points
1,071 views
0 votes
1 answer

To attach a file using mail command on Linux

$ echo | mutt -a syslogs.tar.gz admin@domain.org READ MORE

answered Jun 28, 2019 in Linux Administration by Upasana
• 8,620 points
3,057 views
0 votes
1 answer

Unable to login with GUI on CentOS/RHEL

Hi@akhtar, For new installation of CentOS/RHEL, GUI doesn't ...READ MORE

answered May 11, 2020 in Linux Administration by MD
• 95,460 points
2,992 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 11, 2018 in Python by Priyaj
• 58,020 points
794 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 21, 2018 in Python by Priyaj
• 58,020 points
2,544 views
0 votes
1 answer

How to pass large records to map/reduce tasks?

Hadoop is not designed for records about ...READ MORE

answered Sep 25, 2018 in Big Data Hadoop by Frankie
• 9,830 points
1,562 views
0 votes
1 answer

Invalid method parameters for eth_sendTransaction

params needs to be an array, try {"jsonrpc":"2.0","method":"eth_se ...READ MORE

answered Sep 28, 2018 in Blockchain by digger
• 26,740 points
2,021 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP