opengl with glfw not linking with imgui c++ [duplicate] - c++

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 1 year ago.
I am learning opengl and decided to use imgui to an working existing opengl cmake project by adding following files in the project:
target_sources(Application PRIVATE
vendor/include/imgui/imgui.cpp
vendor/include/imgui/imgui_draw.cpp
vendor/include/imgui/imgui_impl_glfw.cpp
vendor/include/imgui/imgui_impl_opengl3.cpp
vendor/include/imgui/imgui_widgets.cpp
vendor/glad/glad.c
vendor/include/stb_image/stb_image.c
src/Indexbuffer.cpp
src/Shader.cpp
src/Texture.cpp
src/Vertexarray.cpp
src/Vertexbuffer.cpp
)
while this works fine on windows but when i build it in linux linker shows error saying:
in function `ImGui_ImplOpenGL3_Init(char const*)':
imgui_impl_opengl3.cpp:148: undefined reference to `glGetIntegerv'
imgui_impl_opengl3.cpp:230: undefined reference to `glEnable'
imgui_impl_opengl3.cpp:231: undefined reference to `__glewBlendEquation'
all other glfw and opengl functions are working in my application.cpp it only breaks when i add imgui files to the project.

the problme is not imgui but the lib glfw and glew. so it seem you have not link the libs

Related

Code::Blocks builder error: undefined reference to `WinMain' [duplicate]

This question already has an answer here:
why my code is showing error undefined reference to `WinMain#16'?
(1 answer)
Closed 3 months ago.
How to fix the following error message when trying to compile C++ console application project on Code::Blocks?
undefined reference to `WinMain'
All other questions on Stack Overflow are about "WinMain#16", which is not the case here.
WinMain is linked to in windows when you want to create a windows application.
https://learn.microsoft.com/en-us/windows/win32/learnwin32/winmain--the-application-entry-point
For the complier to look for the main function you will have to change at the linker stage that it is a console application and not a windowed one.
Or you might just need to restart CodeBlocks:
C++ undefined reference to WinMain#16 (Code::Blocks)
Or you might have just have deleted main() ;)

Graphics.h c++ undefined reference to various functions like line(),initgraph() [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 11 months ago.
#include<graphics.h>
#include<stdio.h>
main()
{
int gd=DETECT,gm;
int i,x,y;
initgraph(&gd,&gm,"");
line(0,0,640,0);
line(0,0,0,480);
line(639,0,639,480);
line(639,479,0,479);
for(i=0;i<=1000;i++)
{
x=rand()%639;
y=rand()%480;
putpixel(x,y,15);
}
getch();
closegraph();
}
The Following is a Basic Graphic Program,It Shows the Errors as
undefined reference to 'initgraph'
undefined reference to 'closegraph'
undefined reference to 'line'[4 times]
undefined reference to 'putpixel'
Compiler : CodeBlocks; Language:c++;
I Have Copied the graphics.h and winbgim.h in include folder and the libbgi.a in the lib folder also i have linked all the libraries required to be linked. Please Help.
Change
initgraph(&gd,&gm,"");
to
initgraph(&gd,&gm,NULL);
for compiling:
g++ -o filename filename.cpp -lgraph
to execute:
./filename
The functions in graphics.h are only supported by old ancient Turbo C and Turbo C++ compilers. Those functions can not be used by any modern 32-bit compiler. You can either get a copy of that old MS-DOS compiler or use win32 api GDI functions or get one of several graphics libraries such as OpenGL and QT.

Code::Blocks winmain#16 after creating a class [duplicate]

This question already has answers here:
undefined reference to `WinMain#16'
(7 answers)
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 8 years ago.
I always get this error 'Undefined reference to WinMain#16' after creating a class in Code::Blocks. I have to restart it to make the program works.
Why ?
Thank you!
If you have only one file - your class - and you trying to compile it, you will get this error because file don't have int main() function. It's required by linker to create executable (start point of program).
If you have project with classes, you must have one main function, for example in main.cpp file :)
Also, check that you selected a Console application - GUI (Windows application) neeed WinMain function instead of classical main.
Of course, this is about normal program - library have other requirements.

How to use GLUT in DEV C++? [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 7 years ago.
The compiler throws errors like:
" [Linker error] main.o:main.cpp:(.text+0x972): undefined reference to `_imp__glutReshapeFunc#4' "
Do you know how to use GLUT in Dev C++?
DevC++ is seriously outdated. I recommend using Codeblocks instead.
The error line you quoted simply indicated, that the linker is missing the functions of the GLUT library. Including the headers is not enough (they just provide the compiler with sort of an index). But the linker still needs to be told which libraries to actually link against.

What is the meaning of these ' undefined reference to __glut*WithExit ' OpenGL linker errors? [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 5 years ago.
Original Question:
[Warning] passing GLfloat' for
converting 2 ofvoid
glutSolidSphere(GLdouble, GLint,
GLint)'
[Warning] passing GLfloat'
for converting 3 ofvoid
glutSolidSphere(GLdouble, GLint,
GLint)'
After applying one of the poster's suggestions of including glut.h, I now get this problem.
I can't use glutSolidSphere() without it.
[Linker error] undefined reference to
`__glutInitWithExit#12'
[Linker error] undefined reference to
`__glutCreateWindowWithExit#8'
[Linker error] undefined reference to
`__glutCreateMenuWithExit#8'
[Linker error] undefined reference to
`glutSolidSphere#16'
I'm using DEV C++, if that helps.
That looks mangled. Perhaps it's telling you that you're passing a GLfloat where a GLint was expected, as the 2nd and 3rd arguments? Please paste your exact error/warning output again, this doesn't look right.
The 'slices' and 'stacks' params are supposed to be integers; your code is passing in floats.
Edit: you really shouldn't edit your question to make it a completely different question. Undefined Reference means that you aren't linking in the library that contains those functions. You need to include GLuT in the list of libraries you're linking against.
As DNS said, but in simpler terms:
You need to link the GLUT library. I believe it is usually glut32.lib on Win32 machines. There should be an option for this somewhere in the project properties pages of your IDE; Sorry, I don't use Dev-C++, but in Visual Studio it is in the project properties, and then linker settings, and "Additional Library Includes".
Pass -lglut32 option to mingw's linker - Dev-Cpp uses mingw.
You'll have to find "linker options" textbox somewhere in Project Options. Sorry I cannot be more specific than that, it's been over a year since I used Dev-Cpp, and over three years since I really used it. It should be the same place where you added -lopengl32 and -lglu32.
Don't forget to install the GLUT devpak.
GLUTMingw32.zip file contains all files necessary to build under devcpp
I extracted it on desktop . added lib and include directories from devcpp project-project options menu to include and lib directories .
after added in project options dialog on parameters tab - > linker :
../../../../Dev-Cpp/lib/libopengl32.a
../../../../Dev-Cpp/lib/libglu32.a
../GLUTMingw32/GLUTMingw32/lib/libglut32.a
first two are in devcpp install dir/lib folder
/you can use -lopengl32 and -lglu32 instead , it works/
third one ,libglut32.a , I added from extracted GLUTMingw32.zip folder
placed glut32.dll in folder where project got generated and main.cpp resides
thats all .
after I got Permission denied
I just removed generated exe file and recompiled
if exe can't be deleted close devcpp
if it complains about short redefinition
add at the top of main.cpp
"# define _WCHAR_T_DEFINED"
without quotes