• What is a good way to debug unresolved externals
    7 replies, posted
I am currently dealing with some unresolved externals that came out of the blue. I was deleting a class constructor and BOOM! Unresolved externals. Rebuilding and clearing didnt help. And since I (mostly) have no idea what I am doing in terms of debugging I wanted to ask if someone could tell me some actual debugging techniques when dealing with unresolved externals/symbols. So. Please give me some tips!
Are you talking c++? Generally this means you have a function declared but no definition or a library being included but the linker has no knowledge of the library. Also deleting the constructor, what? Why?
[QUOTE=F.X Clampazzo;51901373]Are you talking c++? Generally this means you have a function declared but no definition or a library being included but the linker has no knowledge of the library. Also deleting the constructor, what? Why?[/QUOTE] I have class with multiple constructors but I later noticed a dumb mistake. Also I never used the 2nd constructor. So I deleted it from the class and its implementation. However for some reason that makes linker errors. And yes I am talking about c++.
Can you upload the code giving the error in [code] tags for me? Because usually you'll end up having this issue if you're trying to use a function that doesn't have a body or something weird with the structure of the function's definition. AHH I saw the code in the what do you need help with thread. Okay uhm. Hmm. 1 sec. I honestly haven't even been able to wrap my head around why you have 2 functions of the same name in the first place.
[QUOTE=F.X Clampazzo;51901555]Can you upload the code giving the error in [code] tags for me? Because usually you'll end up having this issue if you're trying to use a function that doesn't have a body or something weird with the structure of the function's definition.[/QUOTE] Well what exactly should I upload? I can literally comment out everything in main including includes and still get it. If you want the header and source of the class: [CODE]#pragma once //____________________REFERENCES___________________________ ///Books //Opengl SUPERBIBLE //_____________________DEFINES_____________________________ #define MAT_MSG_ALREADY_ENABLED -1 #define MAT_MSG_ALREADY_DISABLED -2 #define MAT_MSG_SUCCESSFUL 1 //____________________INCLUDES_____________________________ #include <GL/glew.h> #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/type_ptr.hpp> #include <vector> #include <JUMA_textures.h> #include <JUMA_color.h> #include <JUMA_texCol.h> #include <JUMA_shaders.h> //____________________STRUCTURES___________________________ struct JUMA_materialFracture{ JUMA_texCol value; materialType type; char* UniformName; GLenum texChannel; bool enabled=true; JUMA_materialFracture() { }; JUMA_materialFracture( JUMA_Texture *Texture, JUMA_color Solid, char *uniformName, GLenum texchannel); JUMA_materialFracture(GLuint *Texture, JUMA_color Solid, char *uniformName, GLenum texchannel); //this is the constructor that I want to delete int disable() { if (!enabled) return MAT_MSG_ALREADY_DISABLED; else enabled = false; return MAT_MSG_SUCCESSFUL; }; int enable(){ if (enabled) return MAT_MSG_ALREADY_ENABLED; else enabled = true; return MAT_MSG_SUCCESSFUL; } }; typedef std::vector<JUMA_materialFracture> JUMA_material; //___________________PROTOTYPES____________________________ int JUMA_passMatToUniforms(JUMA_Shader shader, JUMA_material material);[/CODE] [CODE]#include "stdafx.h" #include <JUMA_materials.h> JUMA_materialFracture::JUMA_materialFracture( JUMA_Texture *Texture, JUMA_color Solid, char *uniformName, GLenum texchannel) { if (Texture == NULL) { value.SolidColor = Solid; type = JUMA_MATCOLOR; } else { value.Texture = *Texture; type = JUMA_MATTEXTURE; } texChannel = texchannel; UniformName =(char*) malloc(sizeof(uniformName)*strlen(uniformName)+1); strcpy(UniformName, uniformName); } JUMA_materialFracture::JUMA_materialFracture(GLuint *Texture, JUMA_color Solid, char *uniformName, GLenum texchannel) { if (Texture == NULL) { value.SolidColor = Solid; type = JUMA_MATCOLOR; } else { value.Texture.id = *Texture; value.Texture.transparent = true; texChannel = texchannel; type = JUMA_MATTEXTURE; } texChannel = texchannel; UniformName = (char*)malloc(sizeof(uniformName)*strlen(uniformName) + 1); strcpy(UniformName, uniformName); } int JUMA_passMatToUniforms(JUMA_Shader shader, JUMA_material material) { for (int i = 0; i < material.size(); i++) { if (material.at(i).enabled) { if (material.at(i).type == JUMA_MATCOLOR) { glUniform4f(glGetUniformLocation(shader.Program, material.at(i).UniformName), material.at(i).value.SolidColor.r, material.at(i).value.SolidColor.g, material.at(i).value.SolidColor.b, material.at(i).value.SolidColor.r); } else { material.at(i).value.Texture.use(material.at(i).texChannel); glUniform1i(glGetUniformLocation(shader.Program, material.at(i).UniformName), material.at(i).texChannel-GL_TEXTURE0); } } } return MAT_MSG_SUCCESSFUL; } [/CODE]
If you take the last working build source and rename the second function in both the header, class file and all usages to something like "JUMA_materialFractureGluint", does it give the errors still? Because I've a sneaking suspicion something somewhere is trying to reference this function instead of the other one like it is supposed to because the linker doesn't know what's going on and confused them somewhere since they have the same name. I could be wrong though, but that would be my guess.
[QUOTE=F.X Clampazzo;51901607]If you take the last working build source and rename the second function in both the header, class file and all usages to something like "JUMA_materialFractureGluint", does it give the errors still? Because I've a sneaking suspicion something somewhere is trying to reference this function instead of the other one like it is supposed to because the linker doesn't know what's going on and confused them somewhere since they have the same name. I could be wrong though, but that would be my guess.[/QUOTE] Yes its working. I understand what went wrong but I do not understand why It didnt work with just deleting the function (because if its gone there cant be an accident right?)
[QUOTE=MoustacheSpy;51901630]Yes its working. I understand what went wrong but I do not understand why It didnt work with just deleting the function (because if its gone there cant be an accident right?)[/QUOTE] Essentially the best way I can explain it is that the program gets the idea that since the first function and the second have the same name, they are the same thing, and so when you had calls to either function it detected one of the same name so clearly it wasn't gone even when deleted as it was still declared by name somewhere, but it wasn't able to find the definition that it wanted for that function since the other function was still actually different by the variables passing in. They would still work when existing together because your calls were passing in the right variables for one of the definitions to work, but because the names were the same it couldn't differentiate on the compiler's side of things. You should be able to safely delete it once the program you're writing it in/compiler successfully understands that you have two distinct, separate functions here instead of something funky between having one function and two as the linker should have made a note of what functions are being declared, defined and called where. I'm sure someone who's actually comp-sci major around here and not an engineering major would be able to explain it better but I'm unfortunately a bit out of my field here otherwise.
Sorry, you need to Log In to post a reply to this thread.