Note: This is a message thread from the old pgfoundry.org forum for pgtclng.
Back to pgtclng home page
Back to archived forum page
By: Justin Crom "invalid argument" with Package Require pgtcl 2011-01-30 23:10 |
My attempt at using pgtcl 1.8.0 hit an immediate snag. I get: couldn't load library "C:/Tcl/lib/Pgtcl1.8.0/libpgtcl.dll": invalid argument while executing "load C:/Tcl/lib/Pgtcl1.8.0/libpgtcl.dll" ("package ifneeded Pgtcl 1.8.0" script) invoked from within "package require Pgtcl" OS XP SP3 Tcl 8.5.9 Postgresql 9.0.2 I first tried the windows binaries installer from this site, then I tried compiling using MinGW and get the same result. I would appreciate any assistance. Warning: I'm a Tcl/Tk newbie. Thanks, JJ |
By: L J Bayuk RE: "invalid argument" with Package Require pgtcl 2011-01-31 23:48 |
Hi, sorry to hear you are having trouble with this. I'm using Tcl-8.5.8 and PostgreSQL-9.0.1 (one minor version lower of each), on XP SP3. I have never seen that "invalid argument" message. (The more common error is "this library or a dependent library could not be found in library path", which usually means the PostgreSQL libraries are not on PATH.) Since "invalid argument" isn't very helpful, I'm going to have to research this. I will probably upgrade Tcl and PostgreSQL on the XP system also, so I have the same versions. Is there else about your environment that might be relevant, different from mine? Is that ActiveState ActiveTcl you are using, or something else? Is this a 64 bit system (not even sure that matters with XP)? |
By: Justin Crom RE: "invalid argument" with Package Require pgtcl 2011-02-01 16:53 |
Thank you for the reply. Funny you should mention the library path problem, as I hit that one at first but figured it out, only to encounter the "invalid argument" message. The OS is 32 bit XP SP3. The TCL is ActiveState (Community edition). Postgresql is the free edition from the EnterpriseDB website...does that make a difference? |
By: L J Bayuk RE: "invalid argument" with Package Require pgtcl 2011-02-01 22:34 |
From what I've found, "invalid argument" is kind of a default error that Tcl throws when "load" fails because the system loader returned an error that Tcl is unable to map to something more specific. Which is generally unhelpful. It doesn't mean the DLL isn't found, nor that a dependent DLL isn't found, nor that the entry point in the DLL is wrong. Those all have specific error messages. In some reported cases, it resulted from an incompatibility of some sort between the Tcl "core" and the extension DLL. I am also using ActiveState ActiveTcl, and EnterpriseDB PostgreSQL. Both are the free ones. One difference is that I used the "zip" packaged EnterpriseDB PostgreSQL binaries, not their one-click installer. But I don't think that matters. Do I have this correct: You initially got "this library or a dependent library could not be found in library path" error when trying to load libpgtcl.dll. You fixed that by putting the EnterpriseDB "bin" directory into your Windows PATH environment. And then you started getting the "invalid argument" message? That might be significant, meaning it is having trouble with the PostgreSQL part. Are you able to run the "psql.exe" command line SQL tool on that PC? I'm going to upgrade my ActiveTcl to 8.5.9.1 (latest Community Edition), which I should have done anyway. EnterpriseDB just put up the new 9.0.3 version of PostgreSQL, so I can't duplicate your 9.0.2, but we will see. I'm also thinking about making up a quick "hello world" Tcl extension, built with MinGW just like libpgtcl.dll, to see if you can load that. |
By: L J Bayuk RE: "invalid argument" with Package Require pgtcl 2011-02-02 02:58 |
I upgraded to ActiveState ActiveTcl-8.5.9.1 (which identifies itself via [info patchlevel] as 8.5.9), and to EnterpriseDB PostgreSQL for Windows 9.0.3. The libpgtcl.dll in pgtclng-1.8.0 loads fine with those. I ran it through my test suite and it passes. I can produce the "invalid argument" error when trying to load libpgtcl.dll, but only by a rather extreme measure: Replace one of the dependent DLLs (such as libpq.dll) with an empty file. This hints at a possible problem with one of your DLLs - perhaps either the file is damaged (corrupt), or there is an architecture mismatch. (EnterpriseDB does have a 64 bit version for Windows, and I presume that would not work...) Here are the PostgreSQL DLLs that I find to be loaded when I am using libpgtcl.dll. (Only libpq.dll is used directly, and it loads the others). Also here is the information I get when I look at file properties (or just "float" the cursor over them in Explorer). Your version numbers may differ, but if you don't see a "company" and "version", that DLL is suspect. (libpq.dll doesn't have a Company, but that's OK. libpgtcl.dll itself shows neither Company nor Version because I was too lazy to figure out how to get them in there...) pgsql\bin\libpq.dll (No company), version 9.0.3.1127 pgsql\bin\libeay32.dll The OpenSSL Project, version 0.9.8.12 pgsql\bin\libiconv-2.dll Free Software Foundation, version 1.12.0.0 pgsql\bin\libintl-8.dll Free Software Foundation, version 0.17.0.0 pgsql\bin\ssleay32.dll The OpenSSL Project, version 0.9.8.12 Could you check these files on your PC? It's a long shot, but I'm running out of ideas. (And if the problem is a Windows system DLL that one of the above depends on, instead of those, there isn't much hope...) |
By: Justin Crom RE: "invalid argument" with Package Require pgtcl 2011-02-02 18:50 |
Thank you for the detailed responses. I apologize for my delay in answering. You asked about the sequence of the error messages. Upon entering "package require Pgtcl" I first rec'd the "this library or a dependent library could not be found..." message. I then added the PostgreSQL bin directory in the Windows PATH, at which point the "invalid argument" began to appear. I am able to run the psql.exe command tool. I'm also able to use ODBC to connect both MS Access and Tcl (via tclodbc package) to the postgres db and manipulate data. You mentioned the prospect of a corrupted dll somewhere along the food chain. I checked the dll's on my machine against the list you sent and the only difference was in the libpq.dll where mine was 9.0.2 and yours was 9.0.3. I dug out another computer with 32 bit XP SP3 (in this case it's XP Home vs. XP Pro on the original). It already had PostgreSQL 9.0.2 installed so I added the ActiveState Tcl and the Pgtclng package. I get the "invalid argument" error on this machine as well. It occurs to me that I may not be installing the Pgtclng package correctly. Is there some install routine that I should run? What I've done is unzip the file to a folder in the Tcl\lib folder and named it "Pgtcl1.8.0". Is there more to set up than that? I guess there could be some critical difference between the 9.0.2 version of libpq.dll and the versions you've run. If I'm allowed time today, I'll upgrade this machine to the 9.0.3 PostgreSQL to see if that shakes something loose. FWIW, I went way beyond my comfort zone and ran Dependency Walker on the libpgtcl.dll from the and found 2 error messages about missing IESHIMS.dll and WER.dll. Not sure if that means anything sinister. Thanks again for your time looking into this. I sure hope I'm not causing you a great inconvenience. Justin |
By: L J Bayuk RE: "invalid argument" with Package Require pgtcl 2011-02-02 23:16 |
OK, those are good tests. That you can run psql.exe points the problem back to libpgtcl itself. Nor do I think this is a PostgreSQL 9.0.2 vs 9.0.3 issue. Pgtclng has no special installation requirements. You should be able to just unzip it anywhere and use the DLL right there (via Tcl [load .../libpgtcl.dll]), provided the system can find the PostgreSQL libpq.dll and its dependencies. Or you can install it in the Tcl library directory and use [package require...]. (By the way, I noticed the Windows release of pgtclng-1.8.0 has incorrect information in README under Installation - it refers to 1.7 and should be 1.8, and refers to a folder "mingw" which isn't there anymore since I stopped building the BCC version.) Running Dependency Walker was a good idea. The IE5SHIMS.DLL and WER.DLL do not seem to be a problem. They are warnings (not errors), on my system anyway, because they are "delay load" and are presumable never used. I get those same warnings for other DLLs too. I'm seeing something possibly suspicious with MSVCR90.DLL (MS C Runtime from Visual Studio 2008). I think this might have come along with OpenOffice.org on my PC. When I run Dependency Walker on libpgtcl.dll, it reports an error on 3 dependencies (libpq, libeay32, ssleay32) not being able to find msvcr90.dll. But when I run Dependency Walker on libpq.dll itself, it has no problems finding msvcr90.dll for those same 3. Do you see MSVCR90.DLL as a dependency (of libpq.dll, for one) when running depends.exe on libpgtcl.dll? |
By: L J Bayuk RE: "invalid argument" with Package Require pgtcl 2011-02-03 03:21 |
I'm out of ideas on this, but I do have a plan B: going back to releasing dual builds of pgtclng for Windows, one built with MinGW and one with the old Borland C++ Builder ("free command line version"). I did that for pgtclng-1.7.2 - the first release built with with MinGW, and the last with Borland. I like MinGW, but something about my build seems to be incompatible with your PCs. I had a tough time building this with Borland due to changes in PostgreSQL-9.0.x, but I did it and it passed my test suite just like the MinGW version. The Borland build includes its own PostgreSQL library (libpq), so it doesn't need any other stuff like EnterpriseDB PostgreSQL on the client. However, it doesn't support SSL connections at all. Would you be willing to try a version built with Borland? |
By: Justin Crom RE: "invalid argument" with Package Require pgtcl 2011-02-03 19:58 |
Last night I installed postgreSQL 9.0.3 (after a complete removal of 9.0.2). Unfortunately, the "invalid argument" error persists. I think the msvcr90.dll comes from the postgreSQL installer. After the 9.0.3 install, the version that now shows up in Depends.exe as a dependency of libpgtcl.dll is in a folder: C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.4974_x-ww_d889290f (note also that msvcr90.dll with the 9.0.3 release is different than the one from the 9.0.2 release) I'd be glad to try the Borland build, but it would sure be nice to have SSL :-) I won't be able to do anything until Friday afternoon, but I'm willing to give it a shot. Thanks for all the effort you're putting into this, Justin |
By: L J Bayuk RE: "invalid argument" with Package Require pgtcl 2011-02-04 01:16 |
Actually I'm not enthusiastic about going back to a Borland version. If you are willing to keep troubleshooting this MinGW version, I would prefer that. I might be making some progress here. I removed OpenOffice.org from my Windows XP PC. This did in fact remove my MSVCR90. And now I get that same "Invalid argument" error when trying to load libpgtcl.dll. Aha! (That is so wrong. Removing OpenOffice breaks pgtclng? Feels like Windows95 again.) But also now my PostgreSQL client (psql.exe) does not work. It also uses MSVCR90, but I suspect it is a different version. According to your info, the "installer" package does include its own MSVCR90, but I used the "binary zip" version which does not. Next step is for me to try the EnterpriseDB installer for PostgreSQL, no OpenOffice.org, and then try building pgtclng. We will see what happens. |
By: Justin Crom RE: "invalid argument" with Package Require pgtcl 2011-02-04 18:30 |
I'm definitely willing to continue testing (and then using! :-) the MinGW version. I think you're onto something with the msvcr90.dll and I look forward to hearing what you find. Justin |
By: L J Bayuk RE: "invalid argument" with Package Require pgtcl 2011-02-23 03:19 |
Sorry for the long delay. I have not made any real progress, although I understand more about the runtime libraries msvcrt.dll and msvcr90.dll. But I cannot explain why running Dependency Walker on libpgtcl.dll gets an error on msvcr90.dll on my PC, but works on yours, nor do I know if this is relevant to the problem. I asked for help on the Tcl newsgroup. I am hoping someone there has some ideas on tracking down the "invalid argument" error. |
By: Justin Crom RE: "invalid argument" with Package Require pgtcl 2011-02-23 19:34 |
No worries about the delay. I wish I could shed some light on what's going on, but I'm no help. I hope others can provide illumination. Justin |
By: L J Bayuk RE: "invalid argument" with Package Require pgtcl 2011-02-25 04:09 |
The only thing I'm coming up with is something we talked about before, DLLs and PATH. libpgtcl.dll uses 1 non-Windows DLL: libpq.dll, which in turn uses 4 non-Windows DLLs: ssleay32.dll libeay32.dll libintl-8.dll libiconv-2.dll. All of these except libpgtcl.dll are supplied with Enterprise-DB PostgreSQL, but Windows will happily load the wrong version of any of these if it finds one earlier. For example (I tested this), if I put an empty file called "libiconv-2.dll" earlier in my PATH than PostgreSQL's bin directory, then when I try to load libpgtcl.dll I will get the same "invalid argument" error you get. (Which of course doesn't prove anything about the actual cause on your PC.) I previously posted that if the PostgreSQL command line tool psql.exe works, then the DLLs are being properly found, so libpgtcl.dll should also work. But it turns out this is not true. Windows looks for DLLs in the application's own directory (where the .exe is found), and in the current working directory, before it tries PATH. Since Enterprise-DB puts the needed DLLs in the same directory as the psql.exe executable, Windows will find those first (before my "bad" file). So my test above, placing an invalid DLL earlier in PATH, results in [load libpgtcl.dll] failing, but psql.exe working. Just like you. So could you check to see if you have any of those 5 dependent DLLs in a directory earlier in your PATH than PostgreSQL's bin directory? |
By: Justin Crom RE: "invalid argument" with Package Require pgtcl 2011-02-26 02:36 |
That's a great question. I just ran a test wherein the PostgreSQL bin directory is the first item in the PATH and the TCL directory is the second item. Unfortunately the error message remains "couldn't load library C:/Tcl/lib/Pgtcl1.8.0/libpgtcl.dll: invalid argument" Justin |