ok im learning how to create and use DLL's
it runse but doesnt import anything from my DLL :S
this is my Main dll cpp file (main.cpp to create the DLL)
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
#include <iostream>
#include <stdio.h>
#pragma warning( disable : -Wno-deprecated )
DllClass::DllClass()
{
}
DllClass::~DllClass()
{
}
int DllClass::Add(int a, int b)
{
return a + b;
}
int DllClass::Sub(int a, int b)
{
return a - b;
}
void DllFunc1(char* a)
{
cout << a << endl;
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
this is dll.h used by the DLL and the APP
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
using namespace std;
extern "C" DLLIMPORT void DllFunc1(char*);
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
int Add(int, int);
int Sub(int, int);
private:
};
#endif /* _DLL_H_ */
and this is main.cpp for the app thats SUPPOSED to get the functions
#include "dll.h"
#include <iostream>
#include <conio.h>
#include <Windows.h>
#include <stdlib.h>
int main()
{
int a, b;
DllClass FromDll;
a = FromDll.Add(2, 2);
b = FromDll.Sub(2, 2);
cout << "Add 2 + 2 =" << a << "!" << endl;
cout << "Subtract 2-2 =" << b << "!" << endl;
getch();
DllFunc1("LOOK!");
getch();
system("PAUSE");
return 0;
}
i am using Dev Cpp and i DID link the .a lib for the dll i made sure i put it in my linker settings
PLEASE HELP!