Hello,

I learn programming using C-language. I'd like to understand how to create and use dll in Dev-C++. Here is a link (in Russian), containing a small Example, which I tried to duplicate in shorter version, but it did not work for me.

https://otvet.mail.ru/question/90107384


Below is what I did, the goal is to define integer in the dll and use it in exe-file.
Maybe anybody experienced in programming could fix my tiny code.

1. ENCODER.h

Code:
#ifndef _ENCODER_H_
#define _ENCODER_H_

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


DLLIMPORT int Number_Dll;


#endif


2. ENCODER.c

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


DLLIMPORT int Number_Dll;


3. ENCODER_RUN.cc


Code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

#include "ENCODER.h"
//#include "ENCODER.dll"


int main() {

//   printf("DLL Const value = %d\n", Number_Dll);
   Number_Dll = 13;

    return 0;

} // int main (int Hours_To_Count) {

Dll was created successfully, but I don't know how to use it.
During compilation of the <ENCODER_RUN.cc> I received an Error and don't know what is wrong.

...\TEST_DLL\collect2.exe [Error] ld returned 1 exit status

Thanks