I did make my dll file out off those two files

dll.h

#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 */

DLLIMPORT void welcome();

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

  private:

};


#endif /* _DLL_H_ */

and dllmain.cpp

/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
#include<iostream>
using namespace std;
DllClass::DllClass()
{

}


DllClass::~DllClass ()
{

}

DLLIMPORT void welcome()
{
  cout << " Welcome home " << 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;
}

now I want to call welcome() function in this DLL from my test_main.cpp

main.cpp

#include <cstdlib>
#include <iostream>
#include<project3.dll> // <<---------- the dll file include 
 
using namespace std;

int main(int argc, char *argv[])
{
    welcome();           // <<------ this function in the DLL
    system("PAUSE");
    return EXIT_SUCCESS;
}

but I got those errors

3 \including dll\main.cpp project3.dll: No such file or directory. 
9 \including dll\main.cpp `welcome' undeclared (first use this function)

I have project.dll in the directory

And when I made the dll file I didn't have anyfile *.lib

I only have a file libProject3.def I tried to include it but it won't work either

any advice please ?

Thanks

include the dll.h header, and not the project3.dll file.

Make an import library - the .lib file, should be an option in your compiler/linker

link the .lib file into your project. The program will know how to access the .dll file from the details stored in the .lib file.

include the dll.h header, and not the project3.dll file.

Make an import library - the .lib file, should be an option in your compiler/linker

link the .lib file into your project. The program will know how to access the .dll file from the details stored in the .lib file.

Thanks man I found out that the lib file was with extinction .a and I just linked in the project options as you said

Thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.