Thread: Runtime Error - Application unable to start correctly

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    139

    Runtime Error - Application unable to start correctly

    Hello, I am trying to get a sqlite database in a 64bit C++ console application. Using the directions below I was able to get the code to compile but I get a runtime error when executing the application.

    askyb.com ยป Establish a connection to SQLite database using C++

    The error is "The application was unable to start correctly (0xc000007b). Click OK to close the application" The only other thing I did that was not in the tutorial is make the build a 64bit application.

    Code:
    
    #include"stdafx.h"
    #include<stdio.h>
    #include<sqlite3.h>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    sqlite3 *db;
    char *zErrMsg = 0;
    int rc;
    
        rc = sqlite3_open("test.db", &db);
    //if (rc){
    //    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); 
    //    exit(0);
    //}
    //else{
    //    fprintf(stderr, "Opened database successfully\n");
    //}
    //sqlite3_close(db);
    return 0;
    }
    
    
    Last edited by EverydayDiesel; 01-26-2014 at 11:50 PM.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    So, did you re-build the Library as 64 bits?

    From 2.3.1 NTSTATUS values
    Code:
    0xC000007B
    STATUS_INVALID_IMAGE_FORMAT
    EDIT2: 64 Bit apps require 64 Bit libraries. An DLL is a library.

    Tim S.
    Last edited by stahta01; 01-27-2014 at 06:53 AM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Jan 2014
    Posts
    139
    Thanks for responding. Yes this is the command that I used to make the lib.

    Code:
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools>vsvars32.bat
    Setting environment for using Microsoft Visual Studio 2010 x86 tools.
    
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools>cd C:\SQLite\lib\64
    
    C:\SQLite\lib\64>lib /def:sqlite3.def /machine:x64
    Microsoft (R) Library Manager Version 10.00.40219.01
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
       Creating library sqlite3.lib and object sqlite3.exp
    
    C:\SQLite\lib\64>

    To get the actual DLL I started a blank dll project (64 bit) and added (sqlite3.h,sqlite3ext.h,shell.c,sqlite3.c) files and compiled the project.
    Then I moved the 64bit DLL to the program directory but still get the same error

    The only modification I had to make to the c code was
    Code:
    #pragma warning(disable: 4996)
    that I had to add because of this error message

    Error 1 error C4996: 'GetVersionExA': was declared deprecated
    Last edited by EverydayDiesel; 01-27-2014 at 11:32 AM.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I have no idea if that is right; (never used MSVC to build Libraries).

    Link to someone post with related error.

    c++ - Runtime error (dll loading) with win32 applications on x64 system, while compiling 0K - Stack Overflow

    Maybe the response will help you.

    I would at least try dependency walker to see if it sees a problem.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User
    Join Date
    Jan 2014
    Posts
    139
    Here is the result output from the compiled dll (64 bit)

    Code:
    C:\Windows\system32>dumpbin /headers C:\SQLite\lib\64\sqlite3.dll
    Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    
    Dump of file C:\SQLite\lib\64\sqlite3.dll
    
    PE signature found
    
    File Type: DLL
    
    FILE HEADER VALUES
                8664 machine (x64)
                   7 number of sections
            52E68E69 time date stamp Mon Jan 27 10:50:49 2014
                   0 file pointer to symbol table
                   0 number of symbols
                  F0 size of optional header
                2022 characteristics
                       Executable
                       Application can handle large (>2GB) addresses
                       DLL
    
    OPTIONAL HEADER VALUES
                 20B magic # (PE32+)
               12.00 linker version
               DAE00 size of code
               2FC00 size of initialized data
                   0 size of uninitialized data
               D83F0 entry point (00000001800D83F0) _DllMainCRTStartup
                1000 base of code
           180000000 image base (0000000180000000 to 000000018010DFFF)
                1000 section alignment
                 200 file alignment
                6.00 operating system version
                0.00 image version
                6.00 subsystem version
                   0 Win32 version
              10E000 size of image
                 400 size of headers
                   0 checksum
                   2 subsystem (Windows GUI)
                 160 DLL characteristics
                       RESERVED - UNKNOWN
                       Dynamic base
                       NX compatible
              100000 size of stack reserve
                1000 size of stack commit
              100000 size of heap reserve
                1000 size of heap commit
                   0 loader flags
                  10 number of directories
                   0 [       0] RVA [size] of Export Directory
              109580 [      3C] RVA [size] of Import Directory
              10B000 [     43C] RVA [size] of Resource Directory
              103000 [    4C2C] RVA [size] of Exception Directory
                   0 [       0] RVA [size] of Certificates Directory
              10C000 [     E10] RVA [size] of Base Relocation Directory
               DC660 [      38] RVA [size] of Debug Directory
                   0 [       0] RVA [size] of Architecture Directory
                   0 [       0] RVA [size] of Global Pointer Directory
                   0 [       0] RVA [size] of Thread Storage Directory
               F0980 [      70] RVA [size] of Load Configuration Directory
                   0 [       0] RVA [size] of Bound Import Directory
              109000 [     580] RVA [size] of Import Address Table Directory
                   0 [       0] RVA [size] of Delay Import Directory
                   0 [       0] RVA [size] of COM Descriptor Directory
                   0 [       0] RVA [size] of Reserved Directory
    
    
    SECTION HEADER #1
       .text name
       DAD65 virtual size
        1000 virtual address (0000000180001000 to 00000001800DBD64)
       DAE00 size of raw data
         400 file pointer to raw data (00000400 to 000DB1FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    60000020 flags
             Code
             Execute Read
    
    SECTION HEADER #2
      .rdata name
       19FA0 virtual size
       DC000 virtual address (00000001800DC000 to 00000001800F5F9F)
       1A000 size of raw data
       DB200 file pointer to raw data (000DB200 to 000F51FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    40000040 flags
             Initialized Data
             Read Only
    
      Debug Directories
    
            Time Type       Size      RVA  Pointer
        -------- ------ -------- -------- --------
        52E68E69 cv           4E 000F0D80    EFF80    Format: RSDS, {604EFA85-24F5-46BE-B4DB-1AFC65FD602D}, 1, C:\Users\Desktop\sqlite3\x64\Debug\
        52E68E69 (   C)       14 000F0DD0    EFFD0
    
    SECTION HEADER #3
       .data name
        CCB1 virtual size
       F6000 virtual address (00000001800F6000 to 0000000180102CB0)
        C000 size of raw data
       F5200 file pointer to raw data (000F5200 to 001011FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    C0000040 flags
             Initialized Data
             Read Write
    
    SECTION HEADER #4
      .pdata name
        54F0 virtual size
      103000 virtual address (0000000180103000 to 00000001801084EF)
        5600 size of raw data
      101200 file pointer to raw data (00101200 to 001067FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    40000040 flags
             Initialized Data
             Read Only
    
    SECTION HEADER #5
      .idata name
        152B virtual size
      109000 virtual address (0000000180109000 to 000000018010A52A)
        1600 size of raw data
      106800 file pointer to raw data (00106800 to 00107DFF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    40000040 flags
             Initialized Data
             Read Only
    
    SECTION HEADER #6
       .rsrc name
         43C virtual size
      10B000 virtual address (000000018010B000 to 000000018010B43B)
         600 size of raw data
      107E00 file pointer to raw data (00107E00 to 001083FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    40000040 flags
             Initialized Data
             Read Only
    
    SECTION HEADER #7
      .reloc name
        1A5E virtual size
      10C000 virtual address (000000018010C000 to 000000018010DA5D)
        1C00 size of raw data
      108400 file pointer to raw data (00108400 to 00109FFF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    42000040 flags
             Initialized Data
             Discardable
             Read Only
    
      Summary
    
            D000 .data
            2000 .idata
            6000 .pdata
           1A000 .rdata
            2000 .reloc
            1000 .rsrc
           DB000 .text
    
    C:\Windows\system32>
    Here is the output from the executable

    Code:
    C:\Windows\system32>dumpbin /headers C:\Users\Desktop\SDBLite\x64\Debug\SDBLite.exe
    Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    
    Dump of file C:\Users\Desktop\SDBLite\x64\Debug\SDBLite.exe
    
    PE signature found
    
    File Type: EXECUTABLE IMAGE
    
    FILE HEADER VALUES
                8664 machine (x64)
                   7 number of sections
            52E6965B time date stamp Mon Jan 27 11:24:43 2014
                   0 file pointer to symbol table
                   0 number of symbols
                  F0 size of optional header
                  22 characteristics
                       Executable
                       Application can handle large (>2GB) addresses
    
    OPTIONAL HEADER VALUES
                 20B magic # (PE32+)
               12.00 linker version
                4E00 size of code
                4A00 size of initialized data
                   0 size of uninitialized data
                1860 entry point (0000000140001860) wmainCRTStartup
                1000 base of code
           140000000 image base (0000000140000000 to 000000014000DFFF)
                1000 section alignment
                 200 file alignment
                6.00 operating system version
                0.00 image version
                6.00 subsystem version
                   0 Win32 version
                E000 size of image
                 400 size of headers
                   0 checksum
                   3 subsystem (Windows CUI)
                8160 DLL characteristics
                       RESERVED - UNKNOWN
                       Dynamic base
                       NX compatible
                       Terminal Server Aware
              100000 size of stack reserve
                1000 size of stack commit
              100000 size of heap reserve
                1000 size of heap commit
                   0 loader flags
                  10 number of directories
                   0 [       0] RVA [size] of Export Directory
                B310 [      50] RVA [size] of Import Directory
                C000 [     43C] RVA [size] of Resource Directory
                A000 [     318] RVA [size] of Exception Directory
                   0 [       0] RVA [size] of Certificates Directory
                D000 [      3C] RVA [size] of Base Relocation Directory
                6880 [      38] RVA [size] of Debug Directory
                   0 [       0] RVA [size] of Architecture Directory
                   0 [       0] RVA [size] of Global Pointer Directory
                   0 [       0] RVA [size] of Thread Storage Directory
                7450 [      94] RVA [size] of Load Configuration Directory
                   0 [       0] RVA [size] of Bound Import Directory
                B000 [     310] RVA [size] of Import Address Table Directory
                   0 [       0] RVA [size] of Delay Import Directory
                   0 [       0] RVA [size] of COM Descriptor Directory
                   0 [       0] RVA [size] of Reserved Directory
    
    
    SECTION HEADER #1
       .text name
        4DCD virtual size
        1000 virtual address (0000000140001000 to 0000000140005DCC)
        4E00 size of raw data
         400 file pointer to raw data (00000400 to 000051FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    60000020 flags
             Code
             Execute Read
    
    SECTION HEADER #2
      .rdata name
        2666 virtual size
        6000 virtual address (0000000140006000 to 0000000140008665)
        2800 size of raw data
        5200 file pointer to raw data (00005200 to 000079FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    40000040 flags
             Initialized Data
             Read Only
    
      Debug Directories
    
            Time Type       Size      RVA  Pointer
        -------- ------ -------- -------- --------
        52E69190 cv           4E 0000781C     6A1C    Format: RSDS, {DDA2EBD0-5511-49A7-827E-6F03EA889365}, 4, C:\Users\Desktop\SDBLite\x64\De
        52E69190 (   C)       14 0000786C     6A6C
    
    SECTION HEADER #3
       .data name
         772 virtual size
        9000 virtual address (0000000140009000 to 0000000140009771)
         200 size of raw data
        7A00 file pointer to raw data (00007A00 to 00007BFF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    C0000040 flags
             Initialized Data
             Read Write
    
    SECTION HEADER #4
      .pdata name
         48C virtual size
        A000 virtual address (000000014000A000 to 000000014000A48B)
         600 size of raw data
        7C00 file pointer to raw data (00007C00 to 000081FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    40000040 flags
             Initialized Data
             Read Only
    
    SECTION HEADER #5
      .idata name
         BD4 virtual size
        B000 virtual address (000000014000B000 to 000000014000BBD3)
         C00 size of raw data
        8200 file pointer to raw data (00008200 to 00008DFF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    40000040 flags
             Initialized Data
             Read Only
    
    SECTION HEADER #6
       .rsrc name
         43C virtual size
        C000 virtual address (000000014000C000 to 000000014000C43B)
         600 size of raw data
        8E00 file pointer to raw data (00008E00 to 000093FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    40000040 flags
             Initialized Data
             Read Only
    
    SECTION HEADER #7
      .reloc name
         118 virtual size
        D000 virtual address (000000014000D000 to 000000014000D117)
         200 size of raw data
        9400 file pointer to raw data (00009400 to 000095FF)
           0 file pointer to relocation table
           0 file pointer to line numbers
           0 number of relocations
           0 number of line numbers
    42000040 flags
             Initialized Data
             Discardable
             Read Only
    
      Summary
    
            1000 .data
            1000 .idata
            1000 .pdata
            3000 .rdata
            1000 .reloc
            1000 .rsrc
            5000 .text
    C:\Windows\system32>

    The dependency walker wont load the executable because of this error

    Code:
    Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
    I am reading for further info

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It should be easier if you grab the source and dump it into your project and compile.
    No need to use libraries. No need to use the command line.
    Just add them to the project and compile using the IDE.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Jan 2014
    Posts
    139
    Quote Originally Posted by Elysia View Post
    It should be easier if you grab the source and dump it into your project and compile.
    No need to use libraries. No need to use the command line.
    Just add them to the project and compile using the IDE.
    I tried that but the files are .c code and visual studio does not like them because the application is c++. Renaming the files to .cpp gives me errors.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You can compile C files in a C++ project just fine. If there are any errors, post 'em.
    (Don't rename the file to ".cpp".)
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Jan 2014
    Posts
    139
    I created a test project and here is the results (for this test I did not rename the files)

    Clicking this error takes me to the very first line of 'sqlite3.c
    Code:
    Error    1    error C1853: 'Debug\SqliteTest.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ 
    and you are using it from C (or vice versa)    c:\users\desktop\sqlitetest\sqlite3.c    1    1    SqliteTest
    Clicking this error takes me to the very first line of shell.c
    Code:
    Error    2    error C1853: 'Debug\SqliteTest.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ 
    and you are using it from C (or vice versa)    c:\users\desktop\sqlitetest\shell.c    1    1    SqliteTest
    Last edited by EverydayDiesel; 01-27-2014 at 11:58 AM.

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by EverydayDiesel
    I tried that but the files are .c code and visual studio does not like them because the application is c++. Renaming the files to .cpp gives me errors.
    You are talking about the SQLite amalgamation file, right? You should be able to configure MSVC to compile it as C, e.g., /Tc, /Tp, /TC, /TP (Specify Source File Type), and perhaps the mere fact that it has a .c file extension should already trigger that.

    Quote Originally Posted by EverydayDiesel
    I created a test project and here is the results (for this test I did not rename the files)
    Create another test project, and during the project creation, uncheck the option to enable precompiled headers.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    Registered User
    Join Date
    Jan 2014
    Posts
    139
    It compiled but what adverse affects does unchecking precompile headers do to the project?

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Right-click the C files in the project and select properties. The select the options as seen in the screenshot.
    For configuration, select all configurations.
    Attached Images Attached Images Runtime Error - Application unable to start correctly-screenshot-2014-01-27-19-01-15-png 
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by EverydayDiesel View Post
    It compiled but what adverse affects does unchecking precompile headers do to the project?
    Precompiled headers speed up compilation time if you are including a lot of headers that takes a long time to compile.
    You can either selectively disable them, create multiple ones (not tested) or disable them entirely.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by EverydayDiesel
    It compiled but what adverse affects does unchecking precompile headers do to the project?
    In a sufficiently large project, you would not benefit from the compilation speed up during development that can result from appropriate use of precompiled headers.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #15
    Registered User
    Join Date
    Jan 2014
    Posts
    139
    Quote Originally Posted by Elysia View Post
    Right-click the C files in the project and select properties. The select the options as seen in the screenshot.
    For configuration, select all configurations.
    Thank you for all the responses. I really appreciate all the help!!!
    Last edited by EverydayDiesel; 01-27-2014 at 02:06 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-18-2012, 04:20 AM
  2. Launching an application within program runtime
    By dav_mt in forum C++ Programming
    Replies: 6
    Last Post: 04-15-2008, 05:46 PM
  3. Unable to start Debian KDE
    By BobS0327 in forum Tech Board
    Replies: 4
    Last Post: 02-07-2006, 09:57 PM
  4. Unable to allocate array size at runtime
    By CookieMonster in forum C Programming
    Replies: 16
    Last Post: 04-03-2004, 06:48 PM
  5. Unable to start pppd
    By taps in forum Linux Programming
    Replies: 5
    Last Post: 10-10-2001, 11:26 PM