#Header file inclusion help
23 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.
Are you making use of header guards?
Show errors, don't describe them
does main.c include mesh.h?
no, mesh.c does
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Okay, let's look at the first error:
mesh.c:(.text+0x0): multiple definition of `LoadShaders'; /tmp/main-a77ff5.o:main.c:(.text+0x0): first defined here
Where is LoadShaders declared and how
declared in include/shader.h, defined in shader.c
okay wait, declarations are also present in shader.h, i was working on shader.c so for now in not using shader.c, neverthe less here is a brief of shader.h:
#ifndef SHADER_M_H
#define SHADER_M_H
#include "glad/glad.h"
#include <cglm/cglm.h>
#include <stdbool.h>
#include <stdio.h> // printf() FILE*
#include <stdlib.h> // malloc()
unsigned int LoadShaders(const char* vertexPath, const char* fragmentPath);
void useShader(unsigned int programID);
void setBool(unsigned int programID, const char* name, bool value);
void setInt(unsigned int programID, const char* name, int value);
void setFloat(unsigned int programID, const char* name, float value);
int loadShaderFromFile(const char* fileName, int shaderType);
void checkCompileErrors(unsigned int shader);
void ShaderCleanUp(unsigned int programID);
// constructor generates the shader on the fly
// ------------------------------------------------------------------------
unsigned int LoadShaders(const char* vertexPath, const char* fragmentPath)
{
// 1. retrieve the vertex/fragment source code from filePath
unsigned int programID;
unsigned int vertex = loadShaderFromFile(vertexPath, GL_VERTEX_SHADER);
unsigned int fragment = loadShaderFromFile(fragmentPath, GL_FRAGMENT_SHADER);
programID = glCreateProgram();
glAttachShader(programID, vertex);
glAttachShader(programID, fragment);
glLinkProgram(programID);
checkCompileErrors(programID);
// delete the shaders as they're linked into our program now and no longer necessary
glDeleteShader(vertex);
glDeleteShader(fragment);
return programID;
}
This is an entire definition, not just a declaration
In C you can't have definitions in headers
yes, for now i have moved it to shader.h
shader.c is under construction
Well this is your error