Linker error when defining function

Hello!

I have a class with a few functions, but I am getting a weird linker error whenever I try to define them.

If I comment out all of the functions, it works fine. If I provide empty definitions, whether on a separate file or not, it also works fine. If this is a definition

1
2
Menu Item; 
m_Sub.push_back(Item);


it stops working. If, instead, the definition is

1
2
Menu Item; 
m_Sub.empty();



it works.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma once
#include "Includes.h"
#include "Clickable.h"

class Menu : public Clickable
{
public:
	
	Menu(){}

	Menu(vector<Menu> Sub);
/*
	vector<Menu>*	        GetSub();

	void			AddSub(Menu Item);

	void			RemoveSub(unsigned int Which);
	
	Menu*			WasInsideSub(int X, int Y);
*/

private:
	vector<Menu> m_Sub;
};




Error when I comment out all of the functions except for the two constructors

Error	4	error LNK1120: 3 unresolved externals	c:\users\jose\documents\visual studio 2012\Projects\Skeleton\Debug\Skeleton.exe	1	1	Skeleton
Error	3	error LNK2001: unresolved external symbol "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)	c:\Users\Jose\documents\visual studio 2012\Projects\Skeleton\Skeleton\Menu.obj	Skeleton
Error	1	error LNK2020: unresolved token (0A000106) "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)	c:\Users\Jose\documents\visual studio 2012\Projects\Skeleton\Skeleton\Menu.obj	Skeleton
Error	2	error LNK2020: unresolved token (0A00014C) "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)	c:\Users\Jose\documents\visual studio 2012\Projects\Skeleton\Skeleton\Menu.obj	Skeleton



Menu.cpp when I got this error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "Menu.h"

Menu::Menu()
{}


Menu::Menu(vector<Menu> Sub)
{
	m_Sub = Sub;
}

/*

Menu*			Menu::WasInsideSub(int X, int Y)
{
	for (vector<Menu>::iterator Iter = m_Sub.begin(); Iter != m_Sub.end(); Iter++)
	{
		if ((*Iter).WasInside(X, Y))
		{
			return &(*Iter);
		}
	}
	return false;
}



//setters and getters
vector<Menu>*	Menu::GetSub(){return &m_Sub;}

void			Menu::AddSub(Menu Item){m_Sub.push_back(Item);}

void			Menu::RemoveSub(unsigned int Which)
{
	if (Which < m_Sub.size())
	{
		m_Sub.erase(m_Sub.begin() + Which);
	}
}*/



Thanks a lot!
I changed [Project] -> Properties -> C/C++ --> Code Generation --> Runtime Library from Multi-threaded DLL (/MD) to Multi-threaded Debug DLL (/MDd) and it builds, but I get this warning:

1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library




edit:

I removed "_DEBUG" from [Project] -> Properties -> C/C++ --> Preprocessor --> Preprocessor Definitions and set it back to /MD and it worked. Why? Also, why did the line m_Sub.push_back(Item) cause the problem?
Last edited on
Anyone?
Topic archived. No new replies allowed.