Thursday, August 13, 2009

How To Create DLL Files in Windows CE or Win32?

When we were trying to develop a pltform and hardware indpendent Media player for In-Vehicle Infotainment systems, our goal was to make every layer Independent!

Normally for every application in embedded domain, we classiy our work as 3 layers. (OSI layers will come after)
1. Application layer
2. OS and Device Driver layer
3. BSP and Hardware layer

Our work belongs to pure application layer where we are using Operating System services to implement our application. Further, our work will be classified as 3 layers.
1. Human Machine Interface (HMI or GUI)
2. Connectivity and Multimedia (CAM)
3. OS layer

We are not concentrating much on hardware and hence Hardware layer is excluded here.

As a first step, we have decided to separate HMI and CAM. To achieve this, creation of DLL file for the CAM layer was necessary.

With the help of some documents and googling, i was succeeded in creation of DLL in VC++ IDE as a static library. In case of static, we will include ".lib" file in the project settings(dependencies). Then the compiler automatically takes the respective DLL from the standard paths.

But it was not useful for us. Then we came to know about '.def' files (definition file). Definition file Contains Function names which are to be exported to outside of the module.

Finally we have achieved in Visual Studio 2005 IDE.

Steps to be followed:

1. Create a DLL project
2. Write your implementations without main function.
3. Add a new source file of type '.def'. It will be there is IDE.
3. Add function names which have to be accessed from other modules

The '.def' file will be like

LIBRARY "CAM_DLL_FOR_CE"
EXPORTS
FunctionName1
FunctionName2

If you build the project, you will be getting dll file in Debug/Release directory of ur workspace.

Note:
If you didnt add the '.def' file, you will not able to import the functions of DLL files.

We can discuss how to access the DLL files and its functions, in my next post.

No comments:

Post a Comment