Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Simple class to hold and transfer data Doc->View.
Same class works fine in a test project but not where needed.
What am I missing? Any help appreciated.

LNK2019: unresolved external symbol "public: CSettings::CSettings(void)" referenced in function "protected: CFracturedDoc::CFracturedDoc(void)" (Abbreviated)

C++
// Relevant CSettings.h File Code
#pragma once
#include "stdafx.h"
class CSettings
{
protected:
	double	m_nXMinimum;
	double	m_nXMaximum;
        // More simple variables
public:
	CSettings(void);
	~CSettings(void);
        // Gets and sets - No inline or virtual
};

// Relevant CSettings.cpp Code
#include "stdafx.h"
#include "CSettings.h"
CSettings::CSettings(void)
{
	this->m_nXMinimum = -2.0;
	this->m_nXMaximum = 2.0;
}
CSettings::~CSettings(void)
{
}

// Relevant CDoc.h Code
#pragma once
#include "CSettings.h"
class CFracturedDoc : public CDocument
{
protected:	// Create From Serialization Only
	CFracturedDoc();
	DECLARE_DYNCREATE(CFracturedDoc)
	CSettings* m_cSettings;  // No Grief here
public:
	CSettings* GetSettings(void);
};
// Relevant CDoc.cpp problem causing Code
#include "stdafx.h"
#include "CSettings.h"  // Error with or without include
#include "CFracturedDoc.h"
CFracturedDoc::CFracturedDoc()
{
	m_cSettings = new CSettings();  // Unresolved External Reference Grief
}
Posted
Updated 20-Aug-14 9:28am
v2
Comments
David O'Neil 20-Aug-14 15:31pm    
Are you sure you added the CSettings unit to your non-test project properly? Are the include directories correct?

PS - I edited your question to use a code block. Please use them in the future. It makes it much easier on us.
nv3 20-Aug-14 15:33pm    
Looks like you haven't told the linker about your CSettings.obj file. If you are using your own make file, include CSettings in it. If you are using a VS project, then include CSettings.cpp/.h in your project.
Sergey Alexandrovich Kryukov 20-Aug-14 16:00pm    
Not to confuse OP: including *.h won't be enough. An object files should also be added. :-)
—SA

1 solution

in Visual Studio you must include the header and source (*cpp) files in the solution.

You must "Add existing item to project/solution..." with CSettings.h and CSettings.cpp.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900