Reprinted from:
Http://blog.csdn.net/luckwangjing/archive/2010/05/18/5603824.aspx
But there must be some difference, because my compiling environment is ads1.2
Note:
1. Development Environment: vs2005 + brew SDK 3.1.5 sp02 + brew SDK tools 1.1.0 sp06
2. compiling environment: ads1.2
3. Development language: C Language
I. Lib Compilation
1. Create a lib Project
Create a brewappwizard project in the normal way, and use brewlib as the project name. brewlib will be created in the project. c, aeeappgen. c, aeemodgen. c files, remove aeeappgen. c, aeemodgen. c file, go to the brewdir/SDK/src directory (brewdir is the brew SDK installation directory), and copy aeemodgen. c file to the project directory, add it to the project, and then create brewlib. h file to the project directory, as shown in the project directory.
Open aeemodgen. C and delete all content in it. Add the following code:
# Include "aeestdlib. H"
# Ifdef aee_load_dll
_ Declspec (dllexport)
# Endif
Int aeemod_load (ishell * pishell, void * pH, imodule ** ppmod)
{
Return success;
}
Open the brewlib. c file and delete all content.
Open project properties --> General --> configuration type --> select static library (. Lib), and click OK to complete the configuration.
The LIB Project template has been completed.
2. Generate lib files that can be used by the simulator
Now we try to write a lib and add a function.
Open the brewlib. h file and add the following code:
# Ifndef _ brewlib_h
# DEFINE _ brewlib_h
# Include <aeestdlib. h>
# Ifdef _ cplusplus
Extern "C "{
# Endif
# Ifdef _ debug
# Pragma comment (linker, "/nodefaultlib: libcmt. lib ")
# Endif
Int add (int x, int y );
# Ifdef _ cplusplus
}
# Endif
# Endif
Open the brewlib. c file and add the following code:
# Include "brewlib. H"
Int add (int x, int y)
{
Return X + Y;
}
At this time, use vs2005 to compile and generate the Lib file in the project directory. This lib file can only be used on the simulator.
3. Generate o files that can be used by the real machine
The brewlib. Mak file.
Then, Mak compiles the project and generates some O files,
Note: If the CPP file has a class definition, it must include an overload of New Delete. Otherwise, a mak error occurs.
The brewlib. o file is used by the real machine. The brewlib. h file is the header file to be referenced by other projects.
Ii. Use of LIB
Create a brewappwizard project in normal mode, and create a uselib project. Copy the brewlib. H, brewlib. Lib, and brewlib. O files to the project directory.
Open the uselib. c file,
Open uselib Project Properties> connector> input> Add dependency to add brewlib. Lib.
Let's first test the int add (int x, int y); method.
Compile the project.
Brewlib. lib (brewlib. OBJ): Warning lnk4099: PDB "vc80.pdb" not found (use "brewlib. lib "or find in" D:/brewworkspace/brewlib/uselib/vc80.pdb "); link the object as if there is no debugging information
Warning. It doesn't matter. Ignore it.
At this time, the simulator can be used.
If you want to compile the file to a real machine for running, generate the uselib. Mak file and modify the Mak file.
Set the following content
$ (Target). $ (exetype): $ (app_objs)
@ Echo ---------------------------------------------------------------
@ Echo target $ @
$ (LD) $ (link_cmd) $ (target). $ (exetype) $ (lflags) $ (app_objs) $ (link_order)
Change
$ (Target). $ (exetype): $ (app_objs)
@ Echo ---------------------------------------------------------------
@ Echo target $ @
$ (LD) $ (link_cmd) $ (target). $ (exetype) $ (lflags) $ (app_objs) $ (link_order) brewlib. o
Add brewlib. O.
Then, Mak compiles the project and generates the uselib. MOD file. The uselib. MOD file is the executable file on the real machine.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/luckwangjing/archive/2010/05/18/5603824.aspx
Note: Thank you very much for luckwangjing, 3ks