Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Anybody tried compiling SQLite?
SQLite ( http://www.hwaci.com/sw/sqlite/ ) is a lightweight embeddable SQL database engine. I'm trying to compile it to a library to static link with Win32 console mode apps. It's 100% old-style C - the kind of code I used to write in the eighties. It compiles cleanly, except I had to use "relaxed type checking" on two of the modules. I'm currently stuck on a GPF (trying to execute a function through a pointer which happens to be NULL. =:) The pointer in question is in a table of function addresses that _should_ resolve at link time, but all the pointers in the table are NULL. To complicate matters, they are referenced through some complicated #defines. I'm wondering if anybody else has been through this particular problem, which I think might involve linker options. After I post this message I'm going to write a single module that has a similar function table using the same #define tricks to see if I can resolve it on my own. Thanks for reading this. =:) ../frank Jun 24 2003
OK I found the culprit. I'm not sure it's legal C. The following statements are all in one C source file. There's a forward declaration like this: static BtOps sqliteBtreeOps; // struct BtOps is a list of pointers to functions then a little later on, an init function: int sqliteBtreeOpen( /* whatever */ ) { // lots of stuff including this statement pBt->pOps = &sqliteBtreeOps; // pBt is a pointer to a Btree structure // which contains pOps, a pointer to a BtOps structure } Finally at the end of the module: static BtOps sqliteBtreeOps = { fileBtreeClose, // more function names // all functions are in this module }; The functions are executed from other modules using some clever defines to make them look like normal function calls, but they amount to calling pBt->pOps->functionName(arglist); I wrote a minimal module to reproduce the problem. It also GPFed with the null pointer. All the function pointers in sqliteBtreeOps are 0. If I comment out the forward declaration and move the init function below the definition of sqliteBtreeOps, the function pointers are valid and the minimal module works as expected. If this is valid C, is there a compile or link option that will make it work correctly? Walter - I can send you the little module if you think it's a compiler bug. On Tue, 24 Jun 2003 12:53:05 -0500, Frank Albe <falbe mindspring.com> wrote:SQLite ( http://www.hwaci.com/sw/sqlite/ ) is a lightweight embeddable SQL database engine. I'm trying to compile it to a library to static link with Win32 console mode apps. It's 100% old-style C - the kind of code I used to write in the eighties. It compiles cleanly, except I had to use "relaxed type checking" on two of the modules. I'm currently stuck on a GPF (trying to execute a function through a pointer which happens to be NULL. =:) The pointer in question is in a table of function addresses that _should_ resolve at link time, but all the pointers in the table are NULL. To complicate matters, they are referenced through some complicated #defines. I'm wondering if anybody else has been through this particular problem, which I think might involve linker options. After I post this message I'm going to write a single module that has a similar function table using the same #define tricks to see if I can resolve it on my own. Thanks for reading this. =:) ../frank Jun 24 2003
Try reproducing it in a very small (10-20 lines) program. That'll usually make it clear what is going on. -Walter Jun 25 2003
On Wed, 25 Jun 2003 10:18:25 -0700, "Walter" <walter digitalmars.com> wrote:Try reproducing it in a very small (10-20 lines) program. That'll usually make it clear what is going on. -Walter Jun 25 2003
Thanks, I can take it from here. -Walter Jun 27 2003
On Fri, 27 Jun 2003 14:59:16 -0700, "Walter" <walter digitalmars.com> wrote:Thanks, I can take it from here. -Walter Aug 10 2003
"Frank Albe" <falbe mindspring.com> wrote in message news:fkicjvsg8ud5jt82agn575tqgmnv4v0sn0 4ax.com...On Fri, 27 Jun 2003 14:59:16 -0700, "Walter" <walter digitalmars.com> wrote:Thanks, I can take it from here. -Walter Aug 10 2003
I did and only found very minor problems in trying to compile the sqlite.dll. I did notice that the image size when compiled with Digital Mars, Borland or Visual C++ is much larger that the binary they offer, which comes from mingw. I am using the latest beta for Digital Mars, and worked from the IDDE. I did not have a chance to see if it runs yet. George Blat Frank Albe wrote:SQLite ( http://www.hwaci.com/sw/sqlite/ ) is a lightweight embeddable SQL database engine. I'm trying to compile it to a library to static link with Win32 console mode apps. It's 100% old-style C - the kind of code I used to write in the eighties. It compiles cleanly, except I had to use "relaxed type checking" on two of the modules. I'm currently stuck on a GPF (trying to execute a function through a pointer which happens to be NULL. =:) The pointer in question is in a table of function addresses that _should_ resolve at link time, but all the pointers in the table are NULL. To complicate matters, they are referenced through some complicated #defines. I'm wondering if anybody else has been through this particular problem, which I think might involve linker options. After I post this message I'm going to write a single module that has a similar function table using the same #define tricks to see if I can resolve it on my own. Thanks for reading this. =:) ../frank Jun 25 2003
I did and only found very minor problems in trying to compile the sqlite.dll. I did notice that the image size when compiled with Digital Mars, Borland or Visual C++ is much larger that the binary they offer, which comes from mingw. I am using the latest beta for Digital Mars, and worked from the IDDE. I did not have a chance to see if it runs yet. George Blat Frank Albe wrote:SQLite ( http://www.hwaci.com/sw/sqlite/ ) is a lightweight embeddable SQL database engine. I'm trying to compile it to a library to static link with Win32 console mode apps. It's 100% old-style C - the kind of code I used to write in the eighties. It compiles cleanly, except I had to use "relaxed type checking" on two of the modules. I'm currently stuck on a GPF (trying to execute a function through a pointer which happens to be NULL. =:) The pointer in question is in a table of function addresses that _should_ resolve at link time, but all the pointers in the table are NULL. To complicate matters, they are referenced through some complicated #defines. I'm wondering if anybody else has been through this particular problem, which I think might involve linker options. After I post this message I'm going to write a single module that has a similar function table using the same #define tricks to see if I can resolve it on my own. Thanks for reading this. =:) ../frank Jun 25 2003
|