pgtclng archived forum thread

Note: This is a message thread from the old forum for pgtclng.

Back to pgtclng home page
Back to archived forum page

By: L J Bayuk
Building pgtclng with MinGW on Windows
2010-06-01 01:02
This is a continuation of discussion for the bug report "Can't figure out how to do dynamic loading or shared libraries (mingw)", by 'tombert':

"Environment: postgres 8.4.4, MinGW (gcc, make), MinSYS, Windows7, Tcl 8.4"

(Runs configure, it says it cannot figure out how to make dynamic libraries, makes *.o files and stops.)

I have never tried to build pgtclng on Windows using MinGW. (I don't think MinGW existed when I started this.) I've always used Borland C++ Builder.

Thomas added:
"I thinks it's worth trying cause MinGW is as well a kind-of standard in the open-source community..."

By: L J Bayuk
RE: Building pgtclng with MinGW on Windows
2010-06-01 01:15
So I gave it a try. I fetched MinGW, and also the zip file with their compiled PostgreSQL for Windows. All you probably need from the zip file is the libpq.* and include files, but I'm not sure. I did not use the MinGW version of Tcl/Tk - I just kept the ActiveState version of 8.5 which I already had.

I didn't use Gnu configure or "TEA" (Tcl Extension Architecture). I just made up a makefile for MinGW. That makes things easier for a first try. If it works, maybe I will look at using configure, or maybe not. Personally, I think editing a few lines at the top of a Makefile is simple enough, and configure is so complex...

With very little effort, it does compile and builds a DLL (libpgtcl.dll). Which loads into ActiveTcl and can connect to the database.

Unfortunately it does not pass my test suite. Actually, for a first try, it isn't bad. It passes all the tests except for one possible memory leak (probably bogus), and the asynchronous connection tests crashed the Tcl shell with an application popup error. I need to look into this.

I'll post the makefile on this thread.
By: L J Bayuk
makefile not posted
2010-06-01 01:24
> I'll post the makefile on this thread.
No I won't. Forum doesn't preserve tabs.

Need to find another way to do this.
By: Thomas Perschak
RE: makefile not posted
2010-06-03 20:24
Hi - thx for doing that ... If you like please send me the makefile to tombert et gmx at
I'll try in my environment ...

By: L J Bayuk
Got the makefile magic
2010-06-04 01:41
Status is that it was crashing in libpq PQisnonblocking(). I duplicated this with a simple C program, no Tcl, and it also crashed. But today I found the answer in a very recent posting on the MinGW mailing list. A magic gcc option which prevents the crash. So now it passes all the tests.

It is not using GNU autoconf, though. At the very least you will have to edit the makefile and point it to your PostgreSQL and Tcl directories.

By the way, I am using ActiveTcl-8.5.5 and EnterpriseDB PostgreSQL-8.4.4.

The MinGW makefile will be in CVS soon, but I will mail you a copy.
By: L J Bayuk
Have to retest, short delay
2010-06-04 15:45
Sorry, short delay... Found that I had the wrong libpq.dll getting loaded. (I actually have 4 different libpq's on that Windows box, knew of 3 of them but forgot about the one that came with PHP and was in my PATH for a different project.)

So I need to rebuild and retest with the right library.
By: L J Bayuk
RE: Building pgtclng with MinGW on Windows
2010-06-08 00:31
I put mingw.mak, the Makefile for MinGW, into CVS:

Also emailed to Thomas.

Docs were updated too. Logo.