Just compiled SQLite in Visual Studio

classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Just compiled SQLite in Visual Studio

john darnell
Hello Folks:

I just started a big project that needed an internal database manager and SQLite looks like it will fit the bill.  I am old hat with SQL but have absolutely no experience with SQLite, so here's hoping that you folks are a real friendly bunch and will help me get up to speed.

Promise:  I will do my homework first before contacting the list so if the question seems dumb, believe me, I've tried to figure it out on my own.

Okay, now that that's out of the way, here's that first dumb-sounding question.

I got my boss to purchase an O'Reilly book called Using SQLite, and the author makes a rather ominous statement:  "All of the SQLite source is written in C...Make sure you use a vanilla C Compiler."

I just added it to a Visual Studio 8 project, turned off the use of precompiled headers (the project is a C++ project) and compiled the SQLite.c file without any errors.  Is it really that easy, or am I about ready to be hit by a Mac truck filled with bugaboos?

R,
John A.M. Darnell
Senior Programmer
Walsworth Publishing Company
Brookfield, MO
John may also be reached at [hidden email]<mailto:[hidden email]>

Trivia SF question:  In the movie, THE MATRIX, just before Neo and Trinity take a harrowing ride up an elevator shaft holding on to an elevator cable, Neo mutters a single phrase. What is that phrase?



_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Simon Slavin-3

On 29 Nov 2010, at 11:10pm, john darnell wrote:

> here's that first dumb-sounding question.
>
> I got my boss to purchase an O'Reilly book called Using SQLite, and the author makes a rather ominous statement:  "All of the SQLite source is written in C...Make sure you use a vanilla C Compiler."
>
> I just added it to a Visual Studio 8 project, turned off the use of precompiled headers (the project is a C++ project) and compiled the SQLite.c file without any errors.  Is it really that easy, or am I about ready to be hit by a Mac truck filled with bugaboos?

That's not dumb, that's "I've been hurt before.".  But you should definitely use the command-line tool to make a database and see if your application can read it before you relax.

Portability is one of the main design criteria for SQLite.  Unlike most SQL engines you can find these days it needs to run not only on desktop computers but TVs, phones, and tiny little embedded controllers.  The simplest way to make that happen is to write it in C and make sure it compiles on anything with a C compiler available.  It's a handicap in some ways, since the programmers can't use even C++, but it means people developing for any new gadget tend to turn to SQLite.

And if it has to be compilable for a PVR/DVR a Wintel computer is no trouble at all.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

john darnell
Thanks, Simon.  I'll take your advice.  

Oh and BTW, I apologize for the "Mac truck" remark--I meant no offense to my friends who code for the Mac (grin).

R,
John

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> On Behalf Of Simon Slavin
> Sent: Monday, November 29, 2010 5:39 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Just compiled SQLite in Visual Studio
>
>
> On 29 Nov 2010, at 11:10pm, john darnell wrote:
>
> > here's that first dumb-sounding question.
> >
> > I got my boss to purchase an O'Reilly book called Using SQLite, and the author
> makes a rather ominous statement:  "All of the SQLite source is written in C...Make
> sure you use a vanilla C Compiler."
> >
> > I just added it to a Visual Studio 8 project, turned off the use of precompiled
> headers (the project is a C++ project) and compiled the SQLite.c file without any
> errors.  Is it really that easy, or am I about ready to be hit by a Mac truck filled with
> bugaboos?
>
> That's not dumb, that's "I've been hurt before.".  But you should definitely use the
> command-line tool to make a database and see if your application can read it
> before you relax.
>
> Portability is one of the main design criteria for SQLite.  Unlike most SQL engines
> you can find these days it needs to run not only on desktop computers but TVs,
> phones, and tiny little embedded controllers.  The simplest way to make that
> happen is to write it in C and make sure it compiles on anything with a C compiler
> available.  It's a handicap in some ways, since the programmers can't use even
> C++, but it means people developing for any new gadget tend to turn to SQLite.
>
> And if it has to be compilable for a PVR/DVR a Wintel computer is no trouble at all.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Puneet Kishor-2


john darnell wrote:
> Thanks, Simon.  I'll take your advice.
>
> Oh and BTW, I apologize for the "Mac truck" remark--I meant no offense to my friends who code for the Mac (grin).

My Mac is Peterbilt.

> R,
> John
>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]]
>> On Behalf Of Simon Slavin
>> Sent: Monday, November 29, 2010 5:39 PM
>> To: General Discussion of SQLite Database
>> Subject: Re: [sqlite] Just compiled SQLite in Visual Studio
>>
>>
>> On 29 Nov 2010, at 11:10pm, john darnell wrote:
>>
>>> here's that first dumb-sounding question.
>>>
>>> I got my boss to purchase an O'Reilly book called Using SQLite, and the author
>> makes a rather ominous statement:  "All of the SQLite source is written in C...Make
>> sure you use a vanilla C Compiler."
>>> I just added it to a Visual Studio 8 project, turned off the use of precompiled
>> headers (the project is a C++ project) and compiled the SQLite.c file without any
>> errors.  Is it really that easy, or am I about ready to be hit by a Mac truck filled with
>> bugaboos?
>>
>> That's not dumb, that's "I've been hurt before.".  But you should definitely use the
>> command-line tool to make a database and see if your application can read it
>> before you relax.
>>
>> Portability is one of the main design criteria for SQLite.  Unlike most SQL engines
>> you can find these days it needs to run not only on desktop computers but TVs,
>> phones, and tiny little embedded controllers.  The simplest way to make that
>> happen is to write it in C and make sure it compiles on anything with a C compiler
>> available.  It's a handicap in some ways, since the programmers can't use even
>> C++, but it means people developing for any new gadget tend to turn to SQLite.
>>
>> And if it has to be compilable for a PVR/DVR a Wintel computer is no trouble at all.
>>
>> Simon.
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Igor Tandetnik
In reply to this post by john darnell
john darnell <[hidden email]> wrote:
> I just added it to a Visual Studio 8 project, turned off the use of precompiled headers (the project is a C++ project) and
> compiled the SQLite.c file without any errors.

There is no such thing as a C++ project. A project in Visual Studio can happily contain both C and C++ files. By default, file extension determines whether the file is compiled with C or C++ compiler (.c would indicate C), and this could also be overridden in project settings on a per-file basis.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

john darnell
Thanks Igor.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Igor Tandetnik
Sent: Monday, November 29, 2010 7:11 PM
To: [hidden email]
Subject: Re: [sqlite] Just compiled SQLite in Visual Studio

john darnell <[hidden email]> wrote:
> I just added it to a Visual Studio 8 project, turned off the use of precompiled headers (the project is a C++ project) and
> compiled the SQLite.c file without any errors.

There is no such thing as a C++ project. A project in Visual Studio can happily contain both C and C++ files. By default, file extension determines whether the file is compiled with C or C++ compiler (.c would indicate C), and this could also be overridden in project settings on a per-file basis.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Jeff Archer-3
In reply to this post by john darnell
>From: john darnell <[hidden email]>
>Date: Mon, 29 Nov 2010 17:10:04 -0600
>
>I just added it to a Visual Studio 8 project, turned off the use of precompiled
>headers (the project is a C++ project) and compiled the SQLite.c >file without
>any errors.  Is it really that easy, or am I about ready to be hit by a Mac
>truck filled with bugaboos?

I believe it is that easy.  I have been using SQLite 3.6.23 and now 3.7.3 with
VS2008 and VS2010 in both 32 and 64 bit applications for a while now with no
issues.  I have a number of use case with multiple applications (on same
machine) in same db file with no issue as long as writer is not too fast.  I
understand there is a test suite that you can run to test your build of sqlite. 
I have never run it.  I only test the feature functionality of my applications
with the assumption that SQLite will work correctly.  It hasn't let me down yet.

Jeff
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Bob Keeland
In reply to this post by john darnell
OK then I have a newbee question that is actually out of the scope of SQLite. If the only difference between C and C++ is the file extension, then what is the difference between C and C++? I'm thinking of adding a language other than the Visual Basic that I kind of know and would like to know the difference. I've been thinking about Java, but am not sure yet.
Bob Keeland

--- On Tue, 11/30/10, john darnell <[hidden email]> wrote:


From: john darnell <[hidden email]>
Subject: Re: [sqlite] Just compiled SQLite in Visual Studio
To: "General Discussion of SQLite Database" <[hidden email]>
Date: Tuesday, November 30, 2010, 10:25 AM


Thanks Igor.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Igor Tandetnik
Sent: Monday, November 29, 2010 7:11 PM
To: [hidden email]
Subject: Re: [sqlite] Just compiled SQLite in Visual Studio

john darnell <[hidden email]> wrote:
> I just added it to a Visual Studio 8 project, turned off the use of precompiled headers (the project is a C++ project) and
> compiled the SQLite.c file without any errors.

There is no such thing as a C++ project. A project in Visual Studio can happily contain both C and C++ files. By default, file extension determines whether the file is compiled with C or C++ compiler (.c would indicate C), and this could also be overridden in project settings on a per-file basis.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



     
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Simon Slavin-3

On 1 Dec 2010, at 1:01am, Bob Keeland wrote:

> OK then I have a newbee question that is actually out of the scope of SQLite. If the only difference between C and C++ is the file extension,

No.

> then what is the difference between C and C++? I'm thinking of adding a language other than the Visual Basic that I kind of know and would like to know the difference. I've been thinking about Java, but am not sure yet.

Argh.  C++ is C, with some additional features added to all object-oriented programming and some other stuff.  So every C program is a C++ program, with the programmer never having chosen to use those extra facilities.  And every C++ compiler can compile a C program.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Jay Kreibich
On Wed, Dec 01, 2010 at 01:10:51AM +0000, Simon Slavin scratched on the wall:

> So every C program is a C++ program,

  Not true.
 
  Try to compile sqlite3.c with a C++ compiler and see how far you get.

   -j

--
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Bob Keeland
In reply to this post by Simon Slavin-3
Oh, from the various replies I see that C++ is a more capable extension of C. Igor was only using a figure of speech, kind of. Sorry about the newbee question, but thanks for the replies.
 
Bob Keeland

--- On Tue, 11/30/10, Simon Slavin <[hidden email]> wrote:


From: Simon Slavin <[hidden email]>
Subject: Re: [sqlite] Just compiled SQLite in Visual Studio
To: "General Discussion of SQLite Database" <[hidden email]>
Date: Tuesday, November 30, 2010, 7:10 PM



On 1 Dec 2010, at 1:01am, Bob Keeland wrote:

> OK then I have a newbee question that is actually out of the scope of SQLite. If the only difference between C and C++ is the file extension,

No.

> then what is the difference between C and C++? I'm thinking of adding a language other than the Visual Basic that I kind of know and would like to know the difference. I've been thinking about Java, but am not sure yet.

Argh.  C++ is C, with some additional features added to all object-oriented programming and some other stuff.  So every C program is a C++ program, with the programmer never having chosen to use those extra facilities.  And every C++ compiler can compile a C program.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



     
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Simon Slavin-3
In reply to this post by Jay Kreibich

On 1 Dec 2010, at 1:33am, Jay A. Kreibich wrote:

> On Wed, Dec 01, 2010 at 01:10:51AM +0000, Simon Slavin scratched on the wall:
>
>> So every C program is a C++ program,
>
>  Not true.
>
>  Try to compile sqlite3.c with a C++ compiler and see how far you get.

Can you explain the problem to me ?  The only C++ compiler I have here handles Obj-C as well and has no problem with it.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

jreidthompson
On 11/30/2010 8:42 PM, Simon Slavin wrote:

> On 1 Dec 2010, at 1:33am, Jay A. Kreibich wrote:
>
>> On Wed, Dec 01, 2010 at 01:10:51AM +0000, Simon Slavin scratched on the wall:
>>
>>> So every C program is a C++ program,
>>   Not true.
>>
>>   Try to compile sqlite3.c with a C++ compiler and see how far you get.
> Can you explain the problem to me ?  The only C++ compiler I have here handles Obj-C as well and has no problem with it.
>
which compiler are you using?
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Igor Tandetnik
In reply to this post by Bob Keeland
Bob Keeland <[hidden email]> wrote:
> OK then I have a newbee question that is actually out of the scope of SQLite. If the only difference between C and C++ is the
> file extension, then what is the difference between C and C++?

Since the premise of the question is false, any conclusion whatsoever may logically follow.

C and C++ are two separate languages, somewhat related but nevertheless distinct. Just as it is customary to give Java sources a .java extension, it is customary to give C sources a .c extension and C++ sources a .cpp or .cc or sometimes .c++ extension. Just as the choice of file extension is not the only difference between Java and C++ (or Python, or Perl, or whatever), it's not the only difference between C and C++.

Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Simon Slavin-3
In reply to this post by jreidthompson

On 1 Dec 2010, at 1:46am, Reid Thompson wrote:

> On 11/30/2010 8:42 PM, Simon Slavin wrote:
>> On 1 Dec 2010, at 1:33am, Jay A. Kreibich wrote:
>>
>>> On Wed, Dec 01, 2010 at 01:10:51AM +0000, Simon Slavin scratched on the wall:
>>>
>>>> So every C program is a C++ program,
>>>  Not true.
>>>
>>>  Try to compile sqlite3.c with a C++ compiler and see how far you get.
>> Can you explain the problem to me ?  The only C++ compiler I have here handles Obj-C as well and has no problem with it.
>>
> which compiler are you using?

Oh.  No matter.  It's the one Apple's Xcode calls and it's being very clever about what language it's compiling.  It defeated my test.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Igor Tandetnik
In reply to this post by Simon Slavin-3
Simon Slavin <[hidden email]> wrote:
> So every C program is a C++ program

Not quite true. Here are a few examples that are valid C but invalid C++:

/* implicit 'int' return type */
f();  

/* implicit conversion from void* to any pointer type */
char* p = malloc(100);

// calling a function without first declaring it.
undeclared(42);

// K&R style function definitions.
void f(x)
    int x;
{
}

It is true, however, that it's fairly easy to transform any C program into a program that's both valid C and C++, by applying straightforward modifications - tightening type safety and such.
--
Igor Tandetnik


_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Igor Tandetnik
In reply to this post by Bob Keeland
Bob Keeland <[hidden email]> wrote:
> Oh, from the various replies I see that C++ is a more capable extension of C. Igor was only using a figure of speech, kind of.

Everything I said in this thread so far, I meant quite literally. Which expression of mine do you take as a figure of speech?
--
Igor Tandetnik


_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

jreidthompson
In reply to this post by Simon Slavin-3
On 11/30/2010 9:04 PM, Simon Slavin wrote:
> Oh.  No matter.  It's the one Apple's Xcode calls and it's being very clever about what language it's compiling.  It defeated my test.
>
> Simon.
a quick google query seems to imply that Xcode uses the Gnu Compiler
Collection (gcc, g++,  gcj, gfortan, etc)   see
http://en.wikipedia.org/wiki/GNU_Compiler_Collection the STRUCTURE
section about midway down and http://gcc.gnu.org/ for the complete details
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Dustin Sallings
In reply to this post by Igor Tandetnik

On Nov 30, 2010, at 18:04, Igor Tandetnik wrote:

> It is true, however, that it's fairly easy to transform any C program into a program that's both valid C and C++, by applying straightforward modifications - tightening type safety and such.

        Except there are a lot of areas where C advanced in C99 that C++ can't deal with in current versions:

        item_info info = { .nvalue = 1 };
 
        struct {
                char blah[];
        }

        char blah[somevariable];

        The ability to sprintf a size_t or any general 64-bit number.

        (and a few other things that are really convenient, but have got in my way in attempts to port c code to c++).

--
dustin sallings

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Just compiled SQLite in Visual Studio

Igor Tandetnik
Dustin Sallings <[hidden email]> wrote:
> On Nov 30, 2010, at 18:04, Igor Tandetnik wrote:
>
>> It is true, however, that it's fairly easy to transform any C program into a program that's both valid C and C++, by applying
>> straightforward modifications - tightening type safety and such.
>
> Except there are a lot of areas where C advanced in C99 that C++ can't deal with in current versions

True. I should have clarified that I meant a C90 program. In my defense, I work primarily with Visual Studio compilers, which don't support C99 (except for the most trivial features, e.g. // comments).
--
Igor Tandetnik


_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
12