When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
89 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
do you have the lib folder linked and -lglfw?
you need to actually link a compiled version of the library youre using, like alex is saying
you are linking the headers, not the actual library
check the coderunner settings, it should implicitly call some compiler to actually run your code, then tell us which one its calling, by default it uses g++/gcc IIRC
if you are using linux, i could share a makefile to make compiling and running pretty easy to grasp, and not require any vscode extensions
oh wait i forgot glfw is header only, what you need todo is link opengl
i assuming you have an opengl lib somewhere in your system
oh shoot im confusing myself
i think its optional
are you using windows?
linux?
thats linux yeah
then use a makefile or cmake
# Source directories separated by space
# Example ./ src1/ src2/
SRCDIR =
# Where individual object files are put.
OBJDIR = target/
# Include directories separated by space
INCDIR =
# Where to put the actual binary after
BINDIR =
TARGET = main
# Compiler
CXX = g++
# Retrieve list of the source files
SRC = $(wildcard $(addsuffix *.cpp,$(SRCDIR)))
# Generate list of the object files
OBJ = $(addprefix $(OBJDIR), $(patsubst %.cpp, %.o, $(notdir $(SRC))))
VPATH = $(SRCDIR)
# Compilation flags
CXXFLAGS =
$(TARGET) : $(OBJ)
@echo Linking...
@mkdir -p $(BINDIR)
@$(CXX) $(CXXFLAGS) -o $(BINDIR)$@ $(OBJ)
$(OBJDIR)%.o : %.cpp
@echo Compiling $< in $@...
@mkdir -p $(OBJDIR)
@$(CXX) $(CXXFLAGS) $(addprefix -I,$(INCDIR)) -c -o $@ $<
heres the one i use for every project i make, its really handy
just remember to add the source directories where the cpp files are,
its run by just typing make
i looked you can get opengl bindings with glad
Im assuming youre looking at https://www.learnopengl.com, then yeah you should def use glad
add -lglfw to the cxxflags
hold up klemme see how id do it in your particular makefile
I had a generated glad.c file
where did that end up
you need to link glad now
follow what alex is saying
is this the only error now?
thats good youre just missing glad then
follow what alex has said
and generate a glad.c file, and remember to put it in a directory that is being compiled
yes
i think you want at least gl 3.3 core iirc
if its lover than 3.3 or 3.0 then its usually deprecated and made to run on really old stuff
anything modern supports AT LEAST 3.3
i got glad for macos where gl is deprecated so maybe its not right for you
well i mean if youre on mac and not using metal then why even bother
youre just begging to be screwed
I don't want to write metal using c++ without apple tooling
xcode is way to slow and big on my kinda old x86 system
thats fair
i mean macos is a closed system anyways
its deliberately made to be coded on mac, for mac
3.3 should probably work
either works
gles is not really needed but bind it anyway if youj want to
after making it, download the zip and just drag the files you got in whatever way you find comfortable
what do you mean?
did you link glad
lmaoo
did you actually compile it
nope
you already got the .c file
can you show me what the top of your glad.c file looks?
the first few lines, until it includes the header
and remember that in whatever file youre using glfw, which should be main.cpp in your case, to include
#include "dir_to_glad/glad.h"
this is glad.c right
are you including glad in main.cpp
same one?
shift them around, it will probably work
idk why it just does
<> means its in a predetermined directory, like your stdlib
"" is a relative directory
<> looks in the library folders of the compiler "" implies a user provided header
are you initializing glad before calling any gl function?
mmhh
nvmd i misread the error
you did compile glad? thats a linker warning
^^^^
${CXX} -c glad.c -o glad
wait are you using the make file you sent me?
or the one i sent
# Source directories separated by space
# Example ./ src1/ src2/
SRCDIR = src/
# Where individual object files are put.
OBJDIR = target/
# Include directories separated by space
INCDIR =
# Where to put the actual binary after
BINDIR =
TARGET = main
# Compiler
CXX = g++
# Retrieve list of the source files
SRC = $(wildcard $(addsuffix *.cpp,$(SRCDIR)))
# Generate list of the object files
OBJ = $(addprefix $(OBJDIR), $(patsubst %.cpp, %.o, $(notdir $(SRC))))
VPATH = $(SRCDIR)
# Compilation flags
CXXFLAGS =
$(TARGET) : $(OBJ)
@echo Linking...
@mkdir -p $(BINDIR)
@$(CXX) $(CXXFLAGS) -o $(BINDIR)$@ $(OBJ)
$(OBJDIR)%.o : %.cpp
@echo Compiling $< in $@...
@mkdir -p $(OBJDIR)
@$(CXX) $(CXXFLAGS) $(addprefix -I,$(INCDIR)) -c -o $@ $<
``` use exactly this one, and run it by typing `make` in the terminal, should give no problems
because whats happening is, the code has a declaration of the function, but no actual function body to compile and link
so regardless of what the makefile is doing, that glad.c sure as hell aint being compiled
oh ffs
just run g++ src/main.cpp src/glad.c -o main
well at least it compiles
are you initializing glad
put this at the start after making context current
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
} ```
put it after GLFWmakecontextcurrent
corrected it
lmk if it works
hell yeah
feel free to close this
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
np