Create fail for window produced by OWL 2.5

I am unable to run an .exe outside of the Borland c++4.5
environment. I presume I need a dll or something for this windows executable to run by itself. Can you help?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try use staticaly linked libraries in your application.
Good luck.
keithdigiAuthor Commented:
Can you explain what statically linked libraries are and where I can find reference materials on the net.
Compile and run this application and it will tell you which DLLs your exe needs.

This is from Windows Developer's Journal, August, 1995

Listing 2: module.h — Header file for module.c
#define E_NFILE   1 // cannot open executable file
#define E_NMODULE 2 // cannot find module
#define E_NMAGIC  3 // not an executable
#define E_OLDAPP  4 // not a Windows executable
#define E_CORRUPT 5 // corrupt executable image
typedef struct tagMODULE {
    char szName[9];     // module name
    char szFile[128];   // module file name
    BOOL fImported;     // module is imported
    struct tagMODULE *pNext;
typedef void (CALLBACK* MODERRPROC)(int, LPSTR);
VOID    FreeModuleList(LPMODULE);
/* End of file */

Listing 1: module.c — Source code for resolving imported DLLs
// compile with STRICT defined and large memory model.
#include <windows.h>
#include <string.h>
#include <malloc.h>
#include <io.h>
#include <direct.h>
#include "module.h"
int     GetImportFileName(LPSTR, LPSTR, LPSTR, int);
#define EMAGIC      0x5A4D
typedef struct tagEXEHDR {
    WORD wSignature;  // executable signature
    WORD wExtraBytes; // number of bytes in last page
    WORD wPages;      // number of pages in file
    WORD wRelocItems; // number of entries in relocation table
    WORD wHeaderSize; // size of header, in paragraphs
    WORD wMinAlloc;   // minimum allocation
    WORD wMaxAlloc;   // maximum allocation
    WORD wInitSS;     // initial SS value
    WORD wInitSP;     // initial SP value
    WORD wCheckSum;   // checksum
    WORD wInitIP;     // initial IP value
    WORD wInitCS;     // initial CS value
    WORD wRelocTable; // offset to relocation table
    WORD wOverlay;    // overlay number
#define NEMAGIC     0x454E
#define NEHDROFF    0x3C
typedef struct tagNEWEXEHDR {
    WORD wSignature;     // new executable signature
    BYTE bVersion;       // linker version number
    BYTE bRevision;      // linker revision number
    WORD wEntryTable;    // relative offset to entry table
    WORD wEntryTableSize;  // size of entry table
    DWORD dwCheckSum;    // CRC checksum of file
    WORD wFlags;         // flags
    WORD wAutoDS;        // automatic data segment
    WORD wHeapSize;      // size of local heap
    WORD wStackSize;     // size of stack
    WORD wInitIP;        // initial IP value
    WORD wInitCS;        // initial CS value
    WORD wInitSP;        // initial SP value
    WORD wInitSS;        // initial SS value
    WORD wSegmentTableSize; // segments in segment table

    WORD wModuleTableSize;  // entries in module table
    WORD wNonResNameTableSize; // non-resident name table size
    WORD wSegmentTable;  // offset to segment table
    WORD wResourceTable; // offset to resource table
    WORD wResNameTable;  // offset to resident name table
    WORD wModuleTable;   // offset to module ref. table
    WORD wImportTable;   // offset to import name table
    WORD wNonResNameTable; // offset to non-resident name table
    WORD wMovable;       // number of movable entry points
    WORD wAlignment;     // alignment shift for segment data
    WORD wResourceSeg;   // resource segment count
    BYTE bExeType;       // target operating system
    BYTE bOtherFlags;    // other EXE flags
    WORD wGangLoad;      // relative offset to gangload area
    WORD wGangLoadSize;  // size of gangload area
    WORD wMinSwapSize;   // minimum code swap size
    WORD wExpVersion;    // expected version number for Windows
#if defined(__BORLANDC__)
    #include <dir.h>
    #define _getcwd getcwd
    #define _access access
#elif defined(__WATCOMC__)
    #define _getcwd getcwd
BOOL GetImportModules(LPMODULE *ppModuleList,
                    LPSTR pszFileName, MODERRPROC ShowError)
    HFILE hf;
    EXEHDR oldhdr;
    NEWEXEHDR newhdr;
    WORD wNewExeOffset, wModOffset, wModules;
    BYTE cbNameLen;
    LONG lTablePos, lNamePos;
    char szModuleName[9], szModulePath[128];
    char szModuleFile[128];
    char *p;
    if ((hf = _lopen(pszFileName, READ)) == HFILE_ERROR) {
        ShowError(E_NFILE, pszFileName);
        return FALSE;
    lstrcpyn(szModulePath, pszFileName,
    if ((p = strrchr(szModulePath, '\\')) != NULL)
        *(p+1) = '\0';
    else {
        _getcwd(szModulePath, sizeof(szModulePath)-1);
        if (szModulePath[lstrlen(szModulePath)-1] != '\\')
            lstrcat(szModulePath, "\\");
    // Read in the old-style executable header block;

    if (_lread(hf, &oldhdr, sizeof(EXEHDR)) !=
        sizeof(EXEHDR)) {
        ShowError(E_NMAGIC, pszFileName);
        return FALSE;
    // Verify that this is an executable file
    if (oldhdr.wSignature != EMAGIC) {
        ShowError(E_NMAGIC, pszFileName);
        return FALSE;
    // Verify that this is a Windows executable
    if (oldhdr.wRelocTable < 0x40) {
        ShowError(E_OLDAPP, pszFileName);
        return FALSE;
    // Read the offset to the NE header block
    _llseek(hf, (LONG)NEHDROFF, 0);
    _lread(hf, &wNewExeOffset, sizeof(WORD));
    // Read in the NE header block
    _llseek(hf, (LONG)wNewExeOffset, 0);
    if (_lread(hf, &newhdr, sizeof(NEWEXEHDR)) !=
        sizeof(NEWEXEHDR)) {
        ShowError(E_CORRUPT, pszFileName);
        return FALSE;
    // Check the NE signature
    if (newhdr.wSignature != NEMAGIC) {
        ShowError(E_CORRUPT, pszFileName);
        return FALSE;
    // Get the module name for this executable
    _llseek(hf, (LONG)(wNewExeOffset+newhdr.wResNameTable), 0);
    _lread(hf, &cbNameLen, sizeof(BYTE));
    _lread(hf, szModuleName, (int)cbNameLen);
    szModuleName[cbNameLen] = '\0';
    AppendModuleList(ppModuleList, szModuleName,
                     pszFileName, FALSE);
    // Calculate the absolute offset of the module table
    lTablePos = (LONG)(wNewExeOffset + newhdr.wModuleTable);
    wModules = newhdr.wModuleTableSize;
    while (wModules > 0) {    
        // Seek to the next entry in the module table
        _llseek(hf, lTablePos, 0);
        _lread(hf, &wModOffset, sizeof(WORD));
        // Calculate offset to the module name
        lNamePos = (LONG)(wNewExeOffset +
            newhdr.wImportTable + wModOffset);
        _llseek(hf, lNamePos, 0);
        // Read module name
        _lread(hf, &cbNameLen, sizeof(BYTE));

        _lread(hf, szModuleName, (int)cbNameLen);
        szModuleName[cbNameLen] = '\0';
        // Check if module is in table and add if needed
        if (!InModuleList(*ppModuleList, szModuleName)) {
            if (!GetImportFileName(szModuleName, szModulePath,
                szModuleFile, sizeof(szModuleFile)))
                ShowError(E_NMODULE, szModuleName);
            else {
                if (AppendModuleList(ppModuleList,
                    szModuleName, szModuleFile, TRUE)) {
                    if (!GetImportModules(ppModuleList,
                                  szModuleFile, ShowError)) {
                        return FALSE;
        wModules--, lTablePos += sizeof(WORD);
    return TRUE;
int GetImportFileName(LPSTR pszModuleName,
        LPSTR pszModulePath, LPSTR pszModuleFile,
        int cbNameLen)
    HMODULE hModule;
    OFSTRUCT of;
    char szBaseName[15];
    // Get module name from in-memory module table  
    if ((hModule = GetModuleHandle(pszModuleName)) != 0)
        return GetModuleFileName(hModule, pszModuleFile,
    // Search for the module filename
    lstrcpy(szBaseName, pszModuleName);
    lstrcat(szBaseName, ".DLL");
    of.cBytes = sizeof(OFSTRUCT);
    if (OpenFile(szBaseName, &of, OF_EXIST|OF_SEARCH) !=
        HFILE_ERROR) {
        lstrcpyn(pszModuleFile, of.szPathName, cbNameLen);
        return lstrlen(pszModuleFile);
    } else {
        char szPathName[128];
        lstrcpy(szPathName, pszModulePath);
        lstrcat(szPathName, szBaseName);
        if (_access(szPathName, 0) != -1) {
            lstrcpyn(pszModuleFile, szPathName, cbNameLen);
            return lstrlen(pszModuleFile);
    return 0;
BOOL InModuleList(LPMODULE pModuleList, LPSTR pszModuleName)
    while (pModuleList) {
        if (!lstrcmp(pszModuleName, pModuleList->szName))

            return TRUE;
        pModuleList = pModuleList->pNext;
    return FALSE;
BOOL AppendModuleList(LPMODULE *ppModuleList, LPSTR
    pszModuleName, LPSTR pszModuleFile, BOOL fFlag)
    LPMODULE pNewModule;
    pNewModule = (LPMODULE)malloc(sizeof(MODULE));
    if (!pNewModule)
        return FALSE;
    lstrcpyn(pNewModule->szName, pszModuleName, 9);
    lstrcpyn(pNewModule->szFile, pszModuleFile, 128);
    pNewModule->fImported = fFlag;
    pNewModule->pNext = (LPMODULE)NULL;
    if (!*ppModuleList)
        *ppModuleList = pNewModule;
    else {
        LPMODULE pLastModule = *ppModuleList;
        while (pLastModule->pNext)
            pLastModule = pLastModule->pNext;
        pLastModule->pNext = pNewModule;
        pLastModule = pNewModule;
    return TRUE;
VOID FreeModuleList(LPMODULE pModuleList)
    LPMODULE pFree;
    while (pModuleList) {
        pFree = pModuleList;
        pModuleList = pModuleList->pNext;
/* End of file */

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Statically linked libraries are libs that are linked in when your  linker links.  You can set this option by right clicking on your exe in the project view, select Target Expert, select static.  What this does essentially is link the DLLs at link time instead of requiring you to supply the DLLs.  Also, set you PATH environment to your \LIB directory and the system will get your LIB from there.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.