Download PGI User's Guide
Transcript
–Mmakeimplib Generate an import library without generating a DLL. Use this flag when you want to generate an import library for a DLL but are not yet ready to build the DLL itself. This situation might arise, for example, when building DLLs with mutual imports (see Example 4 below). –o <file> Passed to the linker. Name the DLL or import library <file>. –def <file> When used with –Mmakedll, this flag is passed to the linker and a .def file named <file> is generated for the DLL. The .def file contains the symbols exported by the DLL. Generating a .def file is not required when building a DLL but can be a useful debugging tool if the DLL does not contain the symbols that you expect it to contain. When used with –Mmakeimplib, this flag is passed to lib which requires a .def file to create an import library. The .def file can be empty if the list of symbols to export are passed to lib on the command line or explicitly marked as dllexport in the source code. –implib <file> Passed to linker. Generate an import library named <file> for the DLL. A DLL’s import library is the interface used when linking an executable that depends on routines in a DLL. To use the PGI compilers to create an executable that links to the DLL form of the runtime, use the compiler flag –Mdll. The executable built will be smaller than one built without –Mdll; the PGI runtime DLLs, however, must be available on the system where the executable is run. The –Mdll flag must be used when an executable is linked against a DLL built by the PGI compilers. The following examples outline how to use –Mmakedll and –Mmakeimplib to build and use DLLs with the PGI compilers. Example 1: Build a DLL out of a single source file, object1.f, which exports data and a subroutine using DLLEXPORT. Build the main source file, prog1.f, which uses DLLIMPORT to import the data and subroutine from the DLL. object1.f: subroutine sub1(i) !DEC$ ATTRIBUTES DLLEXPORT :: sub1 integer i common /acommon/ adata integer adata !DEC$ ATTRIBUTES DLLEXPORT :: /acommon/ print *, "sub1 adata", adata print *, "sub1 i ", i adata = i end prog1.f: program prog1 common /acommon/ adata integer adata external sub1 166 Libraries and Environment Variables