#1
  1. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0

    DBD:Pg, PostgreSQL Source, nmake


    This is an ongoing problem that I'd love to solve. I keep creeping closer to a final solution, but I'd really llike to get there... like... NOW.

    I'm trying to build the DBD::Pg module for Perl to interface to PostgreSQL. I've got cygwin, cygipc and postgres installed and running just peachy (aside from the fact that I mistakenly removed, with force, the entire /usr/local/bin directory in cygwin... oopsy). However, I'm at the end of my rope trying to build DBD::Pg with Visual Studio 6. Here's the latest transcript:
    Code:
    c:/postgres_dir_here/src>nmake /f win32.mak
            cd include
            if not exist pg_config.h copy pg_config.h.win32 pg_config.h
            1 file(s) copied.
            cd ..
            cd interfaces\libpq
            nmake /f win32.mak
    
    Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
    Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
    
    Building the Win32 static library...
    
            if not exist ".\Release/" mkdir ".\Release"
            cl.exe @C:\DOCUME~1\Owner\LOCALS~1\Temp\nma02456.
    dllist.c
            cl.exe @C:\DOCUME~1\Owner\LOCALS~1\Temp\nmb02456.
    md5.c
            cl.exe @C:\DOCUME~1\Owner\LOCALS~1\Temp\nmc02456.
    wchar.c
            cl.exe @C:\DOCUME~1\Owner\LOCALS~1\Temp\nmd02456.
    encnames.c
            cl.exe @C:\DOCUME~1\Owner\LOCALS~1\Temp\nme02456.
    win32.c
    fe-auth.c
    fe-connect.c
    fe-connect.c(805) : error C2143: syntax error : missing ';' before 'type'
    fe-connect.c(850) : error C2065: 'family' : undeclared identifier
    fe-connect.c(885) : error C2065: 'portno' : undeclared identifier
    fe-exec.c
    fe-lobj.c
    fe-misc.c
    fe-print.c
    fe-secure.c
    pqexpbuffer.c
    NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\VC98\bin\N
    MAKE.EXE"' : return code '0x2'
    Stop.
    I have no clue which file it failed on, what the return code is for, or anything else (I HATE nmake with a passion for this very reason). All I know is that U1077 is a generic "the program failed at something, check the return code" error. I can't find any info for the code 0x2.

    At this point, I have a bunch of object files built, but they need to get built to the .lib library. So close... yet so far.

    Any help or suggestions greatly appreciated, as always!

    [edit]
    Here's something that might be of interest. It cds down to a different makefile farther down the directory structure. I ran nmake with the /N option on that makefile and here's the output of commands it runs. I don't know what i'm looking at here really, but maybe someone else will:
    Code:
    Building the Win32 static library...
    
            cl.exe @C:\DOCUME~1\Owner\LOCALS~1\Temp\nma02316
            link.exe -lib @C:\DOCUME~1\Owner\LOCALS~1\Temp\n
            cl.exe @C:\DOCUME~1\Owner\LOCALS~1\Temp\nmc02316
            rc.exe /l 0x409 /fo".\Release\libpq.res" libpq.r
            link.exe @C:\DOCUME~1\Owner\LOCALS~1\Temp\nmd023
            del C:\DOCUME~1\Owner\LOCALS~1\Temp\nma02316.
            del C:\DOCUME~1\Owner\LOCALS~1\Temp\nmb02316.
            del C:\DOCUME~1\Owner\LOCALS~1\Temp\nmc02316.
            del C:\DOCUME~1\Owner\LOCALS~1\Temp\nmd02316.
    I imagine it is failing on one of those two cl.exe calls, but I can't be sure. ATM I'm trying to figure out how to get some echos to execute from the makefile at different steps to see if I can weed out a culprit here (unfortunately, I don't know makefiles :p).
    [/edit]

    [edit2]
    Alright, here's the code chunk in fe-connect.c that's throwing errors. It also appears that the fe-connect.obj file isn't getting built, so maybe that's where cl is bombing out:
    Code:
    #ifdef WIN32
            static int WeHaveCalledWSAStartup;
            if(!WeHaveCalledWSAStartup) {
    //                WSADATA wsaData;
    //                if(WSAStartup(MAKEWORD(1, 1), &wsaData)) {
    //                        printfPQExpBuffer(&conn->errorMessage, "WSAStartup failed: errno=%d\n", h_errno);
    //                        goto connect_errReturn;
     //               }
     //               WeHaveCalledWSAStartup = 1;
            }
    #endif
    Commenting out that inner if(!WeHaveCalledWSAStartup) block allows me to compile fe-connect.c without errors. Uncomment that if() block, however (and leave the meat inside of it commented) and it throws the error:
    Code:
    syntax error : missing ';' before 'type'
    on that line. That error then cascades to an int declaration a few lines later (i.e. it can't declare the ints because apparently there's an unterminated line or something...
    Last edited by Ctb; May 16th, 2003 at 12:30 PM.
  2. #2
  3. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0

    Unhappy Not quite...


    Following up on my morning adventures:

    I commented out the entire offending #ifdef ... #endif block and libpq compiled flawlessly. After wrangling with DBD::Pg for awhile, I managed to get everything built and installed with warnings (closer...). I can 'use DBD::Pg' in my scripts, but when I try to call the DBI->connect() method, I get:
    Code:
    DBI->connect(dbname=names) failed: Could not create socket: WSAStartup not yet called (0x0000276D/10093) at test.pl line 8
    Which apparently leads me back to the b0rked code chunk I commented out....
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    Just a random shot in the dark, but can uncomment all the code and try putting this line
    #include <winsock2.h>
    in fe-connect.c, under all the other #includes, and see what happens.
  6. #4
  7. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0
    Thanks for the tip scorp, but that include directive addition throws 61 errors and 11 warnings out at compile time (including the 3 that I originally was getting) regarding the header file.

    I don't understand what that message is trying to tell me. Through selective commenting / deletions I eventually got it to this point where it would compile ok:
    Code:
    #ifdef WIN32
    
                    WSADATA wsaData;
                    //WSAStartup(MAKEWORD(1, 1), &wsaData);
    
    #endif
    All it did was throw a warning about that lil lonely wsaData sitting there not doing anything. Uncomment that other line though and you get the weird "syntax error : missing ';' before 'type'" error. This is an XP machine using VC++6, and everyone else who used this code chunk used NT with VC++5/6. Could there be a significant difference in the WSAStartup() call between NT and XP that's blowing this up?
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,255
    Rep Power
    2222
    Is it possible that XP is uppity and thinks that version 1.1 of Winsock is beneath it? See what happens when you ask for 2.0:
    Code:
    WSAStartup(MAKEWORD(2, 0), &wsaData);
    I always request 2.0, but that's just because the example I based my first programs on did. I have no idea what the effect would be of requesting a lower number. Unless the functions you're using require higher than 1.1.

    You might also want to test the return value of WSAStartup(). It should be zero if successful. Otherwise, it will return a WSA error code.
  10. #6
  11. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    The code looks just fine as is. The only thing I can think of is maybe the MAKEWORD macro has some comments or something that throws your compiler off?

    What if you did this:
    Code:
    WSADATA wsaData;
    WORD wVerRequested = MAKEWORD(1,1);
    WSAStartup(wVerRequested, &wsaData);
  12. #7
  13. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0
    Nope, thanks for the suggestions though. I tried both, and both caused the same missing token before type error. Commenting this:
    WSAStartup(wVerRequested, &wsaData);
    from Scorpions' suggestion causes the error to go away (and just throws a warning about the unused wsaData instead).

    When I installed this version of Visual Studio, there was something wrong with the installation. It erred out of some step, but at the time it was working on VB6 and it didn't halt the installation process. At the time, I suspected that my documentation had just been fragged by the error because I can't get any of the Help dialogs to work. Is it possible that my installation is damaged and I can't call WSAStartup() for some reason?

IMN logo majestic logo threadwatch logo seochat tools logo