1

Check comment below for update

This is the error report: Cube_Life.obj : error LNK2019: unresolved external symbol "void __cdecl Draw_Coordinates(void)"

Please don't tell me to search, I did that but couldn't find a solution. I have a Help_Functions.h and a Help_Functions.cpp, with their contents shown below.

I declared the function Draw_Coordinates in the .h file and defined it in .cpp and I still get keep getting the error. Even when right clicking on the function and choosing to show the definition, it merely displays search results and it can't find the definition.

I even tried a simple function like void test(){return;} but still the same problem. They are not excluded from build either.

Help_Functions.h

#pragma once
#include "stdafx.h"

void test();


void Draw_Coordinates();

Help_Functions.cpp:

#include "stdafx.h"



void test(){return;}

void Draw_Coordinates()
    {

//definition, it would be unnecessary to put all that code

}

stdafx.h:

#pragma once

#define PI 3.14159265359
#include "targetver.h"


#include <fstream>
#include <sstream>
#include <string>
#include <stdio.h>
#include <tchar.h>
#include <math.h>
#include <windows.h>   // Standard Header For Most Programs
#include <gl/gl.h>     // The GL Header File
#include <GL/glu.h>
#include <gl/glut.h>   // The GL Utility Toolkit (Glut) Header
#include <stdlib.h>
#include <iostream>
#include "OBJECT_3D.h"
#include "Help_Functions.h"
using namespace std;

The weird thing is that OBJECT_3D is not causing any problems. The only difference I can think of is that it had its files created by Visual Studio, but Help_Functions where created individually by me.

Valentin
  • 654
  • 2
  • 7
  • 15
  • 1
    possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – jrok Jul 14 '13 at 13:01
  • I am not sure why you put those headers in stdafx.h. at least should put include "Help_functions.h" in Help_Functions.cpp – billz Jul 14 '13 at 13:05
  • Well, it makes it less messy that way. I added the .h file to the implementation file but still not solving it. – Valentin Jul 14 '13 at 13:09
  • This just doesn't make sense. I made a class called "Helper" and copied the contents of Helper_Functions to Helper's .h and .cpp files. Now it works. But if I remove the "Helper" files, even when using the code from Help_Functions, it stops working. I think I'm going crazy. – Valentin Jul 14 '13 at 13:55
  • OKAY, so this is really crazy. When I rename "Help_Functions.cpp" to anything else, it works. For some reason, it stops working when I retain its original name or rename it back to "Help_Functions.cpp". – Valentin Jul 14 '13 at 14:03
  • Go to your project property sheet, find your compiler and linker **command lines**. Look at them, try to understand what's wrong with them, show them if you can't figure it out. – n. m. could be an AI Jul 14 '13 at 20:20
  • Here are the linker command lines: /OUT:"C:\Users\Dell\Documents\Visual Studio 2010\Projects\Cube_Life\Debug\Cube_Life.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Users\Dell\Documents\Visual Studio 2010\Projects\Cube_Life\Cube_Life" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Debug\Cube_Life.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Dell\Documents\Visual Studio 2010\Projects – Valentin Jul 15 '13 at 07:25
  • ***continued***.... \Cube_Life\Debug\Cube_Life.pdb" /SUBSYSTEM:CONSOLE /PGD:"C:\Users\Dell\Documents\Visual Studio 2010\Projects\Cube_Life\Debug\Cube_Life.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE – Valentin Jul 15 '13 at 07:26
  • Strangely the command line does not list the object files. I guess you need to find the build log then. Look for `Build log was saved at "file path"` in the output window, ctrl-click on the paths and the log will open. Make sure – n. m. could be an AI Jul 16 '13 at 18:43
  • This is a part of the build log, the rest is warnings and errors: Build started 7/18/2013 1:38:42 PM. 1>Project "C:\Users\Dell\documents\visual studio 2010\Projects\Cube_Life\Cube_Life\Cube_Life.vcxproj" on node 2 (build target(s)). 1>InitializeBuildStatus: Creating "Debug\Cube_Life.unsuccessfulbuild" because "AlwaysCreate" was specified. ClCompile: All outputs are up-to-date. C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS – Valentin Jul 18 '13 at 11:51
  • /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"Debug\Cube_Life.pch" /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt Cube_Life.cpp – Valentin Jul 18 '13 at 11:51

2 Answers2

0

First off if you have not already done so, try placing inclusion guards in your header files.

#ifndef HEADERNAME_H
#define HEADERNAME_H

// Code here

#endif

Secondly go to your properties sheet in visual studio. Properties -> Linker -> Input.

Make sure you have all your libs included properly.

Next after you verified all your library files were in there correctly, check 'VC++ Directories' in your properties page.

It seems like the error could also be in your Help_Functions.h file. Was there something you recently did that could possibly cause this error? If you can post your Help_Functions.cpp / h.

Ryan
  • 84
  • 3
  • The libraries are not the problem. Everything is in the right place and no errors related to them. I only get linking errors with functions declared/defined in Help_Functions.h/cpp. test() was working a few hours ago(not "working", more like not causing an error) after I added "#include Help_Functions.h" in the main file, but it doesn't work now. – Valentin Jul 14 '13 at 13:17
0

Is Help_Functions.cpp being compiled? If you have not added that file to the project then the functions in it will be "unresolved". To add the file to the project use the Project menu 'Add Existing Item' command.

ScottMcP-MVP
  • 10,337
  • 2
  • 15
  • 15