Referencing ELBs and OLBs
References enable a project to use other libraries and repositories. Referencing a library is equivalent to linking to a library (i.e., equivalent to adding a library to a dblink command when developing outside of Visual Studio). You can add a reference by right-clicking the Reference node in Solution Explorer and selecting Add Reference from the context menu. Note the following:
- Whenever possible, reference a project rather than a file generated by a project. For instance, it is better to reference a project for an ELB than the .elb file generated by that project. If you reference an .elb file rather than an ELB project, there will be no IntelliSense or prototypes for that ELB, and you will not be able to use the "Require prototype usage (-qreqproto)" option (on the Compile page of Project Designer) to ensure that all routines are validated against prototypes..
A special type of reference (a prototype-only reference) is required to resolve a call from a library early in the build order to a higher-level library (a library later in the build order)—i.e., a circular reference. (Though these references are not supported for classes and class members.) See Creating a prototype-only reference.
We recommend using environment variables when referencing ELBs. Paths to ELBs are hard-coded in applications and libraries that reference them and are limited to 31 characters. To use an environment variable when referencing an ELB, do one of the following:
- Specify the environment variable in the “Output path” field on the Build page of Project Designer, and then use the Project tab of the Visual Studio Reference Manager to add the reference to an ELB project. (See figure 1 below.) For an ELB project, “Output path” is used as the path for project references to the ELB (in addition to defining the location for build files for the project). If you set it to an environment variable, that environment variable will be used as the path for project references to the ELB.
- Use the Synergy tab of the Visual Studio Reference Manager to add a reference to an ELB file. For traditional Synergy projects, the Reference Manger in Visual Studio includes a Synergy tab that makes it easy to add references to ELB and OLB files. This tab lists all ELBs and OLBs in locations specified by DBLDIR, RPSLIB, and WND, as well as locations specified by environment variables set on the Environment Variables and Common Properties pages of Project Designer. If you use this tab, the environment variable specified for the ELB will be used as the path. See figure 2 below.
1. Referencing an ELB project.
2. Referencing an ELB file.
If you use a tab other than the Synergy or Project tab, or if you use the Project tab without specifying an environment variable in “Output path”, the full path to the ELB on the development machine will be hard-coded in the executable or library that references the project (if the path does not exceed 31-characters). The hard-coded path will then be used to locate the ELB on deployment machines.
Keep in mind that if you use environment variables when referencing ELBs, those environment variables must be set on deployment machines. If an environment variable for a referenced ELB is not set on a deployment machine, the Synergy runtime will look for that ELB in the current directory for the running DBR.