Working with DLL functions

1st the compiler output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
obj\app\hexGUI_dbLoad.o:hexGUI_dbLoad.cpp:(.text+0x3103): undefined reference to `_imp__GetTxtFromUI'
obj\app\hexGUI_dbLoad.o:hexGUI_dbLoad.cpp:(.text+0x3221): undefined reference to `_imp__LoadHexT'
obj\app\hexGUI_G.o:hexGUI_G.cpp:(.text+0x1eb): undefined reference to `_imp___ZN4HackD1Ev'
obj\app\hexGUI_G.o:hexGUI_G.cpp:(.text+0x9bb): undefined reference to `_imp___ZN4HackD1Ev'
obj\app\hexGUI_G.o:hexGUI_G.cpp:(.text+0x117b): undefined reference to `_imp___ZN4HackD1Ev'
obj\app\hexGUI_G.o:hexGUI_G.cpp:(.text+0x1ac3): undefined reference to `_imp___ZN4HackC1Ev'
obj\app\hexGUI_G.o:hexGUI_G.cpp:(.text+0x1ed8): undefined reference to `_imp___ZN4HackD1Ev'
obj\app\hexGUI_G.o:hexGUI_G.cpp:(.text+0x2593): undefined reference to `_imp___ZN4HackC1Ev'
obj\app\hexGUI_G.o:hexGUI_G.cpp:(.text+0x29a7): undefined reference to `_imp___ZN4HackD1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text+0x152): undefined reference to `_imp___ZN4HackC1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text+0x30b): undefined reference to `_imp___ZN4HackD1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text+0x32b): undefined reference to `_imp___ZN4HackD1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text+0x3a1): undefined reference to `_imp___ZN4CodeD1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text+0x606): undefined reference to `_imp___ZN4HackD1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text+0x621): undefined reference to `_imp___ZN4HackD1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text$_ZNSt6vectorI4CodeSaIS0_EEaSERKS2_[std::vector<Code, std::allocator<Code> >::operator=(std::vector<Code, std::allocator<Code> > const&)]+0x1ea): undefined reference to `_imp___ZN4CodeD1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text$_ZNSt6vectorI4CodeSaIS0_EEaSERKS2_[std::vector<Code, std::allocator<Code> >::operator=(std::vector<Code, std::allocator<Code> > const&)]+0x5fb): undefined reference to `_imp___ZN4CodeD1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text$_ZNSt6vectorI4CodeSaIS0_EEaSERKS2_[std::vector<Code, std::allocator<Code> >::operator=(std::vector<Code, std::allocator<Code> > const&)]+0x712): undefined reference to `_imp___ZN4CodeD1Ev'
obj\app\hexGUI_hack.o:hexGUI_hack.cpp:(.text$_ZNSt6vectorI4CodeSaIS0_EEaSERKS2_[std::vector<Code, std::allocator<Code> >::operator=(std::vector<Code, std::allocator<Code> > const&)]+0x7ba): undefined reference to `_imp___ZN4CodeD1Ev' 

2nd I have actually defined these and included them using header code like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
xsC_START

bool xsDLL GetHex( void* to, Text  from, ui08 tSize	= 1u, ui08 tType = HEX_TYPE_HEX );
bool xsDLL GetTxt( Text& to, void* from, ui08 fSize	= 1u, ui08 fType = HEX_TYPE_HEX );
bool xsDLL GetHexFromUI( void* to, Text  from, ui08 tSize = 1u );
bool xsDLL GetTxtFromUI( Text& to, void* from, ui08 fSize = 1u );
bool xsDLL GetHexFromSI( void* to, Text  from, ui08 tSize = 1u );
bool xsDLL GetTxtFromSI( Text& to, void* from, ui08 fSize = 1u );
bool xsDLL GetHexFromSF_IEEE754( void* to, Text  from, ui08 tSize = 1u );
bool xsDLL GetTxtFromSF_IEEE754( Text& to, void* from, ui08 fSize = 1u );
// Bool is for Equal (true) / not equal (false), result is 0x0 plus above
bool xsDLL CmpHex( void* compare, void* to, ui08& result, ui08 cSize = 1u, ui08 tSize = 1u, ui08 cType = HEX_TYPE_SF_IEEE754, ui08 tType = HEX_TYPE_SF_IEEE754 );

xsC_END

and src code like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
xsDLL Code::Code(	 void ) { cdeClear(); }
xsDLL Code::~Code( void ) { cdeClear(); }
void xsDLL Code::cdeClear( void )
{
	clear();
	cdeAddr[ 0u ] = 0u;
	cdeAddr[ 1u ] = 0u;
	cdeType	 = 0u;
	cdeSize	 = 0u;
	cdeRam	 = 0u;
	cdeDepth = 0u;
	cdeLoop	 = 0u;
	cdeHex	 = 0u;
	cdeMode	 = 0u;
	cdeInfo	 = 0u;
}

and the xs* stuff is defined like this
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
41
42
43
#ifdef __cplusplus
	#define xsC_START extern "C" {
	#define xsC_END }
#else
	#define xsC_START
	#define xsC_END
#endif

#ifdef __unix__
	#define xsUNIX
	#include <unistd.h>
#elif defined _WIN32
	#define xsMSW
	#include <windows.h>
#elif defined __APPLE__
	#define xsOSX
	#include <TargetConditionals.h>
	#ifdef TARGET_OS_IPHONE
		#define xsOSX_IP
	#elif TARGET_IPHONE_SIMULATOR
		#define xsOSX_IPEMU
	#elif TARGET_OS_MAC
		#define xsOSX_MAC
	#else
		#define xsOSX_OTHER
	#endif
#else
	#define xsUNIV
#endif

#ifdef xsDLL_BUILD
	#ifdef xsMSW
		#define xsDLL __declspec(dllexport)
	#else
		#define xsDLL
	#endif
#else
	#ifdef xsMSW
		#define xsDLL __declspec(dllimport)
	#else
		#define xsDLL
	#endif
#endif 

For me DLLs are foreign territory so I don't know what I did wrong here, any info / explanation would be helpful
That a little more complicated than it needs to be.

Do you link against the .lib file in the project that uses the DLL?

Does the .lib exist? If it doesn't if may indicate that the DLL isn't exporting anything. You can use depends to check the content of the DLL.
Thank you, my problem was that I hadn't linked the generated lib files, as for more complicated than it needs to be, what do you mean?
This
1
2
3
4
5
6
7
8
9
10
11
12
13
#ifdef xsDLL_BUILD
	#ifdef xsMSW
		#define xsDLL __declspec(dllexport)
	#else
		#define xsDLL
	#endif
#else
	#ifdef xsMSW
		#define xsDLL __declspec(dllimport)
	#else
		#define xsDLL
	#endif
#endif  

could be this:
1
2
3
4
5
6
7
8
9
#ifdef xsMSW
	#ifdef xsDLL_BUILD
		#define xsDLL __declspec(dllexport)
	#else
		#define xsDLL __declspec(dllexport)
	#endif
#else
	#define xsDLL
#endif  

Last edited on
That was intended to go with other operating systems as well otherwise I would have done it the way you mentioned, since I don't know anything about the other systems yet I'm just dealing with MSW first then doing the next OS which will be UNIX then OSX then whatever else I can find
Yes, but xsMSW is only defined for Windows by the OS selection block above. So my smaller version is sufficient.
I understand what you're saying and I agree however the reason I left it like that is so I could add in the other operating systems quickly and since it's only a few more cycles spent on compiling it's not a big deal. If all my code was like that then I really would give it a re-think but the way I'm designing it so that will be pretty much the only instance of that style of coding.

Edit: if you happen to know a general reference for OS specific libraries then I would apprieciate a link.
Last edited on
Topic archived. No new replies allowed.