Platform Builder: Cloning – the Linker is your Friend
- by Bruce Eitman
I was tasked this week with making a minor change to NetMsgBox() behavior. NetMsgBox() is a little function in NETUI that handles MessageBox() for the Network User Interface.
The obvious solution is to clone the entire NETUI directory from Public\Common\Oak\Drivers (see Platform Builder: Clone Public Code for more on cloning). If you haven’t already, take a minute to look in that folder. There are a lot of files in the folder, but I only needed to modify one function in one of those files. There must be a better way.
Enter the linker.
Instead of cloning the entire folder, here is what I did:
Create a new folder in my Platform named NETUI (but the name isn’t important)
Copy the C file that I needed to modify to the new folder, in this case netui.c
Copy a makefile from one of the other folder (really they are all the same)
Run Sysgen_capture
Open a build window (see Platform Builder: Build Tools, Opening a Build Window)
Change directories to the new folder
Run “Sysgen_capture netui”
Rename sources.netui to sources
Add the C file to sources as SOURCES=netui.c
Modify the code
Build the code
Done
That is it, the functions from my new folder now replace the functions from the Public code and link with the rest to create NETUI.dll.
There is a catches. If you remove any of the functions from the C file, linking will fail because the remaining functions will be found twice.
Copyright © 2010 – Bruce Eitman
All Rights Reserved