Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

compilation of sqlite3 on dos using djgpp

336 views
Skip to first unread message

mahesh....@gmail.com

unread,
Feb 17, 2013, 8:05:43 AM2/17/13
to
Dear Sir,
I want to compile Sqlite latest version on DOS. When I tried, I was able to make libsqlite3.a To make it work I have used fchown-stub.c But when I tried to link it to shell.o to make exe, it gave me error mmap undefined and munmap undefined. Both of them are defined in sys/stat.h
I think mmap and munmap are specific to linux and there is no equ. in dos.
While porting unix to dos many programmers should be facing the same problem.
Please let me know, how to solve this problem.
Thanking you.

dos...@googlemail.com

unread,
Feb 17, 2013, 2:02:33 PM2/17/13
to
Well, on a lazy Sunday afternoon I tried to compile SQLite too.

The following steps allowed to compile it:

1. run "configure --disable-threadsafe"

2. modify this in sqlite3.c:

#ifdef __DJGPP__
{ "fstat", 0, 0 },
//#define osFstat(a,b,c) 0
#define osFstat(a,b) 0 //djgpp - replacing above
#define MAP_SHARED 0
#define MAP_FAILED 0
#define ETIMEDOUT 9000 //unused number
#define ENOTCONN 9001 //unused number

#else

3. take out munmap:

for(i=0; i<p->nRegion; i++){
if( p->h>=0 ){
//djgpp munmap(p->apRegion[i], p->szRegion);
}else{
sqlite3_free(p->apRegion[i]);
}
}

4. take out mmap:

if( pShmNode->h>=0 ){
/* djgpp
pMem = mmap(0, szRegion,
pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE,
MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion
);
*/
if( pMem==MAP_FAILED ){
rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
goto shmpage_out;
}


Then it did compile and seemed to work so far. The library does not use mmap, only the shell program sqlite3.exe does and I guess that will work so far without mmap in DOS.

Georg

Matthew Petricone

unread,
Feb 17, 2013, 2:01:02 PM2/17/13
to dj...@delorie.com

You could always write your own mmap function. I haven't used djgpp in a while, but you would probably need to use the dpmi functions for large memory allocs. You may be able to leave some mmap functionality out, depending on how sqlite uses it.

-Matt

Georg Potthast

unread,
Feb 17, 2013, 3:50:01 PM2/17/13
to dj...@delorie.com
Yes, commenting out mmap allowed to compile. It should be replaced with an alternative function to allow to read/write the file.

Georg

mahesh....@gmail.com

unread,
Feb 19, 2013, 4:55:55 AM2/19/13
to dj...@delorie.com
On Monday, February 18, 2013 4:50:01 AM UTC+8, Georg Potthast wrote:
> Yes, commenting out mmap allowed to compile. It should be replaced with an alternative function to allow to read/write the file.
>
>
>
> Georg

Thank you so much George !
But despite your good answer my problem is not solved !
I made the changes you suggested. libsq;ite3.a was built. Then I was able to compile shell.c also. But when I tried to produce sqlite3.exe, it gave me error ld cannot find -lgcc and -lc.
I then tried to compile another example which is orking fine on linux also gave the same error !
Now, libgcc.a and libc.a are already there in the lib directory. As sugested in one article, I use DOSLFN for enabling long file names. But the error remains same when I try to use libsqlite3.a !
Now my actual problem is that my pc's IDE bus simply refuses to recognise my HDD or CD drive, where as they work well on another pc.
I am using floppies to boot. I need a program which will work on floppy. That is why I need sqlite binary or library badly.
Can you please send the binary and library you gave built to me by email ?
All my work is held up. I am trying to buy PCI-IDE card which should solve my problem. But till then I have run software on floppies only.
Please help to compile sqlite3 and also please send the binaries to me.
I have written to sqlite developers to keep DOS binaries o their website, but they not even ackowledge my email.
I got one binary sqlitex.zip, which contains corrupt file. It gives disk i/o error.
So please send the binaries to me. my email is mahesh....@gmail.com
Thanking you

Georg Potthast

unread,
Feb 19, 2013, 7:08:04 AM2/19/13
to dj...@delorie.com
I observed that the sqlite3.exe which I compiled from the latest sqlite version shows the help menu fine but it fails to create a table. Since I did not want to go into the sqlite code and modify that I found an older version sqlite-3.5.6 which compiles fine and the resulting sqlite3.exe does work. Do you need the latest version or will this version work for you?

> I got one binary sqlitex.zip, which contains corrupt file. It gives disk i/o error.

As far as I am aware sqlitex.zip is version sqlite-3.3.3 and I also observed this I/O error when I tried it. I followed the instructions on this site:
https://sites.google.com/site/blairdude/sqlite

> So please send the binaries to me. my email is mahesh.s...

I can, but version-3.5.6 is a different database than the latest version so I do not know if that will help you.

Greetings to Mumbai!

Georg


rug...@gmail.com

unread,
Feb 19, 2013, 11:00:42 AM2/19/13
to dj...@delorie.com
Hi,

On Tuesday, February 19, 2013 3:55:55 AM UTC-6, mahesh wrote:
>
> Thank you so much George !
>
> But despite your good answer my problem is not solved !
>
> I made the changes you suggested. libsq;ite3.a was built. Then
> I was able to compile shell.c also. But when I tried to produce
> sqlite3.exe, it gave me error ld cannot find -lgcc and -lc.

Can you quote exactly what commandline invocation was used and
what error message was reported?

> I then tried to compile another example which is orking fine on
> linux also gave the same error !

Then it's something local to your DOS installation, probably
a minor installation error.

> Now, libgcc.a and libc.a are already there in the lib directory.
> As sugested in one article, I use DOSLFN for enabling long file
> names. But the error remains same when I try to use libsqlite3.a !

If you're going to use DOSLFN, you have to install (unzip) with LFNs
enabled too.

> Now my actual problem is that my pc's IDE bus simply refuses to
> recognise my HDD or CD drive, where as they work well on another
> pc.
>
> I am using floppies to boot. I need a program which will work on
> floppy. That is why I need sqlite binary or library badly.
>
> All my work is held up. I am trying to buy PCI-IDE card which
> should solve my problem. But till then I have run software on
> floppies only.

You should be able to boot FreeDOS off of USB also, i.e. RUFUS:

http://rufus.akeo.ie/

At least, it works for me, and gives much more space than a common
1.44 MB floppy.

Georg Potthast

unread,
Feb 19, 2013, 3:37:11 PM2/19/13
to dj...@delorie.com
Rugxulo is right, a USB flash disk would give you much more disk space than a floppy disk. You may try that.

As requested here is my current build of SQLite for you to test:
http://nanox-microwindows-nxlib-fltk-for-dos.googlecode.com/files/mahesh.zip

It is a current snapshot. I usually spend more time testing before posting anything.

Please use a Windows XP DOS box for compiling djgpp programs, it works much faster than real mode DOS with LFN. Also I use gcc 4.5.3 since I observed that some makefiles I had to use did not work with later versions of gcc.

Georg

mahesh....@gmail.com

unread,
Feb 19, 2013, 10:24:45 PM2/19/13
to dj...@delorie.com
Dear George,
I shall be highly thankful to you, if you can send me binaries of any version of sqlite. 3.5.16 will be fine.

The error I was getting for libgcc and libc was because I have not set files=50 on my floppy ( It was on my hdd) When I changed it to files=50 and buffers=40 that error disappeared. However I got new error undefined reference to DLopen.
I just got to know i have to link it with -ldl to get rid of these errors.
STILL I REQUEST YOU TO SEND ME THE BINARIES AT THE EARLIEST. AS I DO NOT HAVE SOURCE FOR ANY PREV. VERSION OF SQLITE.
I can not boot into my USB prndrive directly, but I can bootd into DOS and then using linld.com I can load puppy linux. But I still prefer to work in DOS environment. I have started my computer career long back in 1988. The first PC I used was PC without hard disk only two 360 K Fdd. I purchased my first PC which was PC XT with 20 MB HDD and it was luxury at that time. If I boot into DOS and use sqlite binary it is much faster than using GUI.
Thanking you.
_Mahesh Chavan

rug...@gmail.com

unread,
Feb 20, 2013, 12:09:13 AM2/20/13
to dj...@delorie.com
Hi,

On Tuesday, February 19, 2013 9:24:45 PM UTC-6, mahesh wrote:
>
> The error I was getting for libgcc and libc was because I have not
> set files=50 on my floppy ( It was on my hdd) When I changed it to
> files=50 and buffers=40 that error disappeared.

Okay, good to know, though I'm sure some doc somewhere (I forget
exactly, FAQ?) mentions setting it to at least 40. (BUFFERS isn't
necessary but probably loads faster. If you use a software cache
like UIDE, it's probably not necessary.)

> However I got new error undefined reference to DLopen.
>
> I just got to know i have to link it with -ldl to get rid of
> these errors.

IIRC, DJGPP "current" 2.03p2 doesn't support dlopen(). In fact, only
with "beta" 2.04 DXE3 (and unofficial, third-party DJELF) can
you get it working, but it's usually too problematic for most users.

> I can not boot into my USB prndrive directly,

Have you tried? RUFUS works for me. Even UNetBootIn will work (but
won't save changes). Perhaps you can't "boot" with USB, but maybe
the BIOS still supports it as if it was a hard disk? You can then
"only boot" via floppy but store files on USB. Actually, for a
while, I used PLoP Boot Manager, on my old P4 via floppy, to boot
a USB frugal install of Puppy Linux.

http://www.plop.at/

> but I can bootd into DOS and then using linld.com I can load
> puppy linux. But I still prefer to work in DOS environment.

At least give RUFUS a try before giving up entirely. Or, worst
case, compress the heck out of your files with 7-Zip or UHarc
or whatever (paq8px?). Floppies need all the help they can get!

> If I boot into DOS and use sqlite binary it is much faster
> than using GUI.

"Faster"? Dunno, kinda doubt it. Easier and more convenient?
Yes, definitely. If you don't want GUI, just use something
like "puppy pfix=nox" at the Linux "boot:" loadup screen. Granted,
I'm using an older version, so maybe yours is different, but
that should work. Or use (old, 2.4.x) console-only-by-default
ZipSlack (Slackware 11). Or FreeBSD, which doesn't install X11
by default.

I'm not saying SQLite won't work in DOS, dunno, but sometimes
it's more trouble than it's worth doing things the hard way.

P.S. I had thought Dungeon Crawl: Stone Soup, which dropped DJGPP
support a few years ago, had used SQLite. Maybe it will offer some
tips, e.g. old version 0.5.2.

http://sourceforge.net/projects/crawl-ref/files/Stone%20Soup/0.5.2/

mahesh....@gmail.com

unread,
Feb 20, 2013, 8:29:14 AM2/20/13
to
If I can not use current djgpp to compile sqlite3, I must get some old binaries from somebody.
Yuor suggestion of using pfix=nox is really good suggestion.
I have got Transced * GB pendrive which BIOS show as hard drive. But when I make it bootable, it is shown as pen drive and puppy puts grub on MBR assuming it is sda1. That is why I have to use linld.
You say Rufus worked for you, but can I use fat32 formmatted pendrive to make it bootable by DOS which uses 16 bit fat?
Thanking you.
-Mahesh

Georg Potthast

unread,
Feb 20, 2013, 9:39:19 AM2/20/13
to
Hi Mahesh,

you can download the binaries here:
http://nanox-microwindows-nxlib-fltk-for-dos.googlecode.com/files/mahesh.zip

Georg

mahesh....@gmail.com

unread,
Feb 20, 2013, 1:29:04 PM2/20/13
to
Dear George,
I really do not have words to express my gratitude for your binaries. I downloaded them and ran sqlite3 on my pen drive. It worked !
I have not yet tried to compile freebasic program, but I am sure the library will lso work fine.
Today I am really relived.
I came to know latest sqlite can not be compiled with current djgpp as there is no ld.a and support for dlopen and other functions. There upcoming beta version has support for dlopen. I shall download that and try later.
Right now I have do lot of my pending work.
God bless you dear !
-Mahesh
Many mny thanks to you and the Almighty for his blessings.

Georg Potthast

unread,
Feb 20, 2013, 2:30:55 PM2/20/13
to
Glad I could help and my work was not in vain. I am a bit overwhelmed by your gratitude.

I thought SQLite could be interesting for other DOS users too. So I made a more complete package now for download. This includes example code to use DJGPP with SQLite and instructions and the source code to compile the library and the sqlite3.exe utility:

http://nanox-microwindows-nxlib-fltk-for-dos.googlecode.com/files/sqlite-3.5.6.zip

Georg

mahesh....@gmail.com

unread,
Feb 21, 2013, 5:01:32 AM2/21/13
to
Dear George,
Thank you once again.
I was able to compile a c program ising your sqlite library.
I am loading the exe in RAMDISK as the filesize is about 1.5 MB. But can fit on a 1.72 MB floppy created using FDFormat.

The example given in FREEBASIC sqlite3_test.bas does not compile due to error in sqllite3.bi I have downloaded updated version, but still not working.
Although I use djgpp to compile c program I would like to use sqlite3 in freebasic too.
If you have sqlite3.bi which is working, please let me know.
Thanks.
-Mahesh

Georg Potthast

unread,
Feb 21, 2013, 6:55:59 AM2/21/13
to
The sqlite3.bi file has been made by the FreeBasic team:
'' sqlite3 -- header translated with help of SWIG FB wrapper

The problem (you did not specify the problem) is probably due to the fact that my DOS version is 3.5.6 while the sqlite3.bi file is made from 3.7.8.

So you would have to either:
a) find an old sqlite3.bi file which is based on 3.5.6 somewhere b) use SWIG FB wrapper to make a sqlite3.bi file from my sqlite3.h file
c) compare my sqlite3.h file and the 3.7.8. sqlite3.h file and patch the sqlite3.bi file manually according to the error messages you get from your program.

rug...@gmail.com

unread,
Feb 21, 2013, 7:02:05 PM2/21/13
to
Hi,

On Wednesday, February 20, 2013 7:29:14 AM UTC-6, mahesh wrote:
>
> If I can not use current djgpp to compile sqlite3, I must get
> some old binaries from somebody.

Keep in mind that "current" is only recommended for some people.
DJGPP just never finalized 2.04 (aka, "beta"), but it's also stable.
So there is nothing wrong with using 2.04 instead. Though, again,
due to heavy POSIX-isms in the world today, it's harder than it
should be to use DJGPP, e.g. fork() or dlopen() or similar. There
are workarounds, but they are often hairy. I really don't recommend
messing with DXE3 (or even DJELF) unless you really know what you're
doing.

> Yuor suggestion of using pfix=nox is really good suggestion.
>
> I have got Transced * GB pendrive which BIOS show as hard drive.
> But when I make it bootable, it is shown as pen drive and puppy
> puts grub on MBR assuming it is sda1. That is why I have to use
> linld.

Don't use Puppy to make it bootable. Or, if you do, and your BIOS
won't boot from it, use something like PLoP boot manager via floppy.

> You say Rufus worked for you, but can I use fat32 formmatted
> pendrive to make it bootable by DOS which uses 16 bit fat?

RUFUS uses the latest FreeDOS kernel, which supports FAT12, -16,
and -32. If you use a different DOS instead, it'll probably work,
but make sure your DOS supports FAT32. So MS-DOS 7.0 is fine but
old 6.22 is not.

HILMAN AHWAS A.

unread,
Feb 22, 2023, 9:57:16 AM2/22/23
to
Where do I place those lines of code?

Frank Sapone (emoaddict15@gmail.com) [via djgpp@delorie.com]

unread,
Feb 24, 2023, 1:43:44 PM2/24/23
to dj...@delorie.com
On 2/22/2023 9:57 AM, HILMAN AHWAS A. (hilma...@gmail.com) [via
According to Georg's instructions sqlite3.c from the source code.

Frank

HILMAN AHWAS A.

unread,
Aug 5, 2023, 12:14:49 AM8/5/23
to
In what line numbers? I've obtained the 3.42.0 amalgamation source code

gnufan42 (gnufan42@protonmail.com) [via djgpp@delorie.com]

unread,
Aug 5, 2023, 7:58:39 AM8/5/23
to dj...@delorie.com
------- Original Message -------
On Wednesday, February 22nd, 2023 at PM 10:57, HILMAN AHWAS A. (hilma...@gmail.com) [via dj...@delorie.com] <dj...@delorie.com> wrote:


> On Monday, February 18, 2013 at 2:02:33 AM UTC+7, <@email omitted> wrote:
>
> > Well, on a lazy Sunday afternoon I tried to compile SQLite too.
> >
> > The following steps allowed to compile it:
> >
> > 1. run "configure --disable-threadsafe"
> >
> > 2. modify this in sqlite3.c:
> >
> > #ifdef DJGPP
Why wasn't mmap implemented in the first place?

Eli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com]

unread,
Aug 5, 2023, 8:14:38 AM8/5/23
to dj...@delorie.com
> Date: Sat, 05 Aug 2023 11:58:02 +0000
> From: "gnufan42 (gnuf...@protonmail.com) [via dj...@delorie.com]" <dj...@delorie.com>
>
> Why wasn't mmap implemented in the first place?

Because DPMI 0.9 doesn't support the required functionality, AFAIR.

RayeR

unread,
Oct 2, 2023, 9:38:56 PM10/2/23
to
> > Why wasn't mmap implemented in the first place?
> Because DPMI 0.9 doesn't support the required functionality, AFAIR.

CWSDPMI supports some DPMI 1.0 functions. I implemented a subset of mmap for DOS port of NVclock utility via the __djgpp_map_physical_memory()
0 new messages