brechtsanders / xlsxio

XLSX I/O - C library for reading and writing .xlsx files
MIT License
417 stars 112 forks source link

Tutorial x64 application failed to start. #46

Closed seccpur closed 5 years ago

seccpur commented 5 years ago

Tried with the tutorial code to read xlsx file with VC 2017 in x64 debug mode. Libs were generated from defs and the x64 dlls( including dependencies) were also downloaded . Compiled and built without any error on VC 2017 in 64 bit, but application won't start. Error dialog displays - " The application was unable to start correctly (0xc000007b).". Any help will be appreciated.

#include <xlsxio_read.h>

int main() {

    //open .xlsx file for reading
    xlsxioreader xlsxioread;
    if ((xlsxioread = xlsxioread_open("Transmission_Log.xlsx")) == NULL) {
        fprintf(stderr, "Error opening .xlsx file\n");
        return 1;
    }

    //read values from first sheet
    char* value;
    xlsxioreadersheet sheet;
    const char* sheetname = NULL;
    printf("Contents of first sheet:\n");
    if ((sheet = xlsxioread_sheet_open(xlsxioread, sheetname, XLSXIOREAD_SKIP_EMPTY_ROWS)) != NULL) {
        //read all rows
        while (xlsxioread_sheet_next_row(sheet)) {
            //read all columns
            while ((value = xlsxioread_sheet_next_cell(sheet)) != NULL) {
                printf("%s\t", value);
                free(value);
            }
            printf("\n");
        }
        xlsxioread_sheet_close(sheet);
    }

    //clean up
    xlsxioread_close(xlsxioread);

}
brechtsanders commented 5 years ago

Sounds like typical Windows DLL hell. Have you tried debugging? If it doesn't start maybe the debugger will tell you why. I would also recommend opening the .exe with Dependancy Walker (http://www.dependencywalker.com/) to see if it actually finds all the dependancies the way it should. Note that when running the .exe the .dll must be on the same directory or in folder that is listed in the PATH environment variable, otherwise there is no way the application can start.

seccpur commented 5 years ago

@brechtsanders : Thanks for the quick response. Copied the DLL files into the application directory and the libs files didn't generate any linker error. I haven't checked the dll files on Dependency Walker though. Debugging didn't helped as the application failed to launch during starting itself. As you have said, the problem may be related to DLL library not seamlessly fitting with the application. Your DLL files do not have release and debug versions separately, but I was trying in the debug mode, I give a shot with the release version. thanks anyway.

brechtsanders commented 5 years ago

Yes, only release versions are downloadable. Also you could try static linking if you (statically) build the libraries and the dependancies from source.

seccpur commented 5 years ago

Thanks, works in release mode with the prebuilt binaries. Building static libraries from source will also require static libraries of the dependencies, should be fairly difficult atm.

brechtsanders commented 5 years ago

Okay, glad it works. I'm not sure if debug versions built with MinGW will work with MSVC, so I don't distribute debug versions with binary downloads.