Creating a dynamic library

Write your question here.
I'm trying to create a dynamic library. I went to the projects options and click on the Parameters tab. Add a the library, but came
back with an [Build Error] [file.exe] Error 1. Also is in the MakeFile.win.I'm trying to link a .a library.
https://drive.google.com/file/d/0Bw2HP34V0kobT0dJakhRem5zMTQ/view?usp=sharing
https://drive.google.com/file/d/0Bw2HP34V0kobNU91WjN5X242cUU/view?usp=sharing
https://drive.google.com/file/d/0Bw2HP34V0kobYkFpelFoc192dlE/view?usp=sharing
How do I link a library file in Dev c++?


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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  Put the code you need help with here.
#include <iostream>
#include <cstdlib>
#include "dll.h"
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	DllClass c;
	c.HelloWorld();
	system("PAUSE");
    return EXIT_SUCCESS;
}

/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>

DllClass::DllClass()
{

}

DllClass::~DllClass()
{

}

void DllClass::HelloWorld()
{
	MessageBox(0, "Hello World from DLL!\n","Hi",MB_ICONINFORMATION);
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
	switch(fdwReason)
	{
		case DLL_PROCESS_ATTACH:
		{
			break;
		}
		case DLL_PROCESS_DETACH:
		{
			break;
		}
		case DLL_THREAD_ATTACH:
		{
			break;
		}
		case DLL_THREAD_DETACH:
		{
			break;
		}
	}
	
	/* Return TRUE on success, FALSE on failure */
	return TRUE;
}

#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
#define DLLIMPORT __declspec(dllexport)
#else
#define DLLIMPORT __declspec(dllimport)
#endif

class DLLIMPORT DllClass
{
	public:
		DllClass();
		virtual ~DllClass();
		void HelloWorld();
};

#endif 
closed account (E0p9LyTq)
You have to create two separate projects, one to create the DLL and another (with main) to use the DLL.

Orwell's Dev C++ fork is outdated, the GCC compiler is old.

Support for creating and using custom static and dynamic libraries is better IMO with Visual Studio 2015. VS 2015 Community is free.

Walkthrough: Creating and Using a Dynamic Link Library (C++)
https://msdn.microsoft.com/en-us/library/ms235636.aspx

Last edited on
I did it ,and then added these files in the main project.
Topic archived. No new replies allowed.