Compiling pure virtual functions to dll

Hi

I'm trying to compile this code in to a dll but im getting an error.

Code:
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
#pragma once

#ifdef DLL_BUILD
	#define DECLSPEC __declspec(dllexport)
#else
	#define DECLSPEC __declspec(dllimport)
#endif


#ifdef C_HEADERS
extern "C" {
#endif
namespace My
{

int DECLSPEC TripleMe(int x);
void DECLSPEC DoStuff();

class DECLSPEC MyGame
{
public:
	virtual void Init()=0;
	virtual void Update()=0;
	void Start();
};

}
#ifdef C_HEADERS
}
#endif




error:
1
2
3
4
my.o:my.cpp:(.rdata$_ZTVN2My6MyGameE[__ZTVN2My6MyGameE]+0x8): undefined reference to `__cxa_pure_virtual'
my.o:my.cpp:(.rdata$_ZTVN2My6MyGameE[__ZTVN2My6MyGameE]+0xc): undefined reference to `__cxa_pure_virtual'
my.o:my.cpp:(.rdata$_ZTIN2My6MyGameE[__ZTIN2My6MyGameE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
collect2.exe: error: ld returned 1 exit status 


It happened after i added the 'MyGame' class
Seems to be something to do with the virtual functions

(im on windows using MinGW, btw)
Last edited on
See: https://stackoverflow.com/questions/10703876/gcc-undefined-cxa-pure-virtual
When you get these kinds of weird errors, always try Google first.

By the way, you can't extern "C" a class declaration. That doesn't make sense. extern "C" is used to call C functions from C++. Functions in a class are necessarily C++ functions.
Topic archived. No new replies allowed.