Thread: Compile error with MSVC

Compile error with MSVC

From
Yoshiyuki Asaba
Date:
Hi,

I tried to compile using Visual C++ 2005. But I got the following
errors.

  .\src\backend\parser\keywords.c(22) : fatal error C1083: 'parser/parse.h': No such file or directory


I saw src/tools/msvc/pgbison.bat. Why does it copy
src/backend/parser/parser.h to src/include/parser directory?

src/tools/msvc/pgbison.bat:14

  if "%1" == "src\backend\parser\gram.y" call :generate %1 src\backend\parser\gram.c src\include\parser\parse.h

I think we should add "src/backend" directory to include path. Because
if gram.c is newer than gram.y, include/parser/parse.h does not
copied.

Then, I saw clean.bat. It deletes the files generated by Bison. I
think we don't have to delete these files.

The attached patch for HEAD is fixed them.
Regards,
--
Yoshiyuki Asaba
y-asaba@sraoss.co.jp
Index: Mkvcbuild.pm
===================================================================
RCS file: /projects/cvsroot/pgsql/src/tools/msvc/Mkvcbuild.pm,v
retrieving revision 1.13
diff -c -r1.13 Mkvcbuild.pm
*** Mkvcbuild.pm    12 Jun 2007 18:31:28 -0000    1.13
--- Mkvcbuild.pm    4 Jul 2007 05:07:46 -0000
***************
*** 185,203 ****
--- 185,207 ----

      my $psql = AddSimpleFrontend('psql', 1);
      $psql->AddIncludeDir('src\bin\pg_dump');
+     $psql->AddIncludeDir('src\backend');
      $psql->AddFile('src\bin\psql\psqlscan.l');

      my $pgdump = AddSimpleFrontend('pg_dump', 1);
+     $pgdump->AddIncludeDir('src\backend');
      $pgdump->AddFile('src\bin\pg_dump\pg_dump.c');
      $pgdump->AddFile('src\bin\pg_dump\common.c');
      $pgdump->AddFile('src\bin\pg_dump\pg_dump_sort.c');

      my $pgdumpall = AddSimpleFrontend('pg_dump', 1);
      $pgdumpall->{name} = 'pg_dumpall';
+     $pgdumpall->AddIncludeDir('src\backend');
      $pgdumpall->AddFile('src\bin\pg_dump\pg_dumpall.c');

      my $pgrestore = AddSimpleFrontend('pg_dump', 1);
      $pgrestore->{name} = 'pg_restore';
+     $pgrestore->AddIncludeDir('src\backend');
      $pgrestore->AddFile('src\bin\pg_dump\pg_restore.c');

      my $zic = $solution->AddProject('zic','exe','utils');
***************
*** 293,298 ****
--- 297,303 ----
              if ($f =~ /\/keywords\.o$/)
              {
                  $proj->AddFile('src\backend\parser\keywords.c');
+                 $proj->AddIncludeDir('src\backend');
              }
              else
              {
Index: clean.bat
===================================================================
RCS file: /projects/cvsroot/pgsql/src/tools/msvc/clean.bat,v
retrieving revision 1.5
diff -c -r1.5 clean.bat
*** clean.bat    12 Jun 2007 11:07:34 -0000    1.5
--- clean.bat    4 Jul 2007 05:07:46 -0000
***************
*** 16,50 ****
  REM Delete files created with GenerateFiles() in Solution.pm
  call :del src\include\pg_config.h
  call :del src\include\pg_config_os.h
- call :del src\include\parser\parse.h
  call :del src\include\utils\fmgroids.h

  call :del src\backend\utils\fmgrtab.c
  call :del src\backend\catalog\postgres.bki
  call :del src\backend\catalog\postgres.description
  call :del src\backend\catalog\postgres.shdescription
- call :del src\backend\parser\gram.c
- call :del src\backend\bootstrap\bootparse.c
- call :del src\backend\bootstrap\bootstrap_tokens.h

  call :del src\bin\psql\sql_help.h

  call :del src\interfaces\libpq\libpq.rc
  call :del src\interfaces\libpq\libpqdll.def
  call :del src\interfaces\ecpg\include\ecpg_config.h
- call :del src\interfaces\ecpg\preproc\preproc.c
- call :del src\interfaces\ecpg\preproc\preproc.h

  call :del src\port\pg_config_paths.h

  call :del src\pl\plperl\spi.c
- call :del src\pl\plpgsql\src\pl_gram.c
- call :del src\pl\plpgsql\src\pl.tab.h
-
- call :del contrib\cube\cubeparse.c
- call :del contrib\cube\cubeparse.h
- call :del contrib\seg\segparse.c
- call :del contrib\seg\segparse.h

  if exist src\test\regress\tmp_check rd /s /q src\test\regress\tmp_check
  call :del contrib\spi\refint.dll
--- 16,37 ----
Index: pgbison.bat
===================================================================
RCS file: /projects/cvsroot/pgsql/src/tools/msvc/pgbison.bat,v
retrieving revision 1.6
diff -c -r1.6 pgbison.bat
*** pgbison.bat    17 Mar 2007 17:11:41 -0000    1.6
--- pgbison.bat    4 Jul 2007 05:07:46 -0000
***************
*** 11,17 ****
  goto nobison
  :bisonok

! if "%1" == "src\backend\parser\gram.y" call :generate %1 src\backend\parser\gram.c src\include\parser\parse.h
  if "%1" == "src\backend\bootstrap\bootparse.y" call :generate %1 src\backend\bootstrap\bootparse.c
src\backend\bootstrap\bootstrap_tokens.h
  if "%1" == "src\pl\plpgsql\src\gram.y" call :generate %1 src\pl\plpgsql\src\pl_gram.c src\pl\plpgsql\src\pl.tab.h
  if "%1" == "src\interfaces\ecpg\preproc\preproc.y" call :generate %1 src\interfaces\ecpg\preproc\preproc.c
src\interfaces\ecpg\preproc\preproc.h
--- 11,17 ----
  goto nobison
  :bisonok

! if "%1" == "src\backend\parser\gram.y" call :generate %1 src\backend\parser\gram.c src\backend\parser\parse.h
  if "%1" == "src\backend\bootstrap\bootparse.y" call :generate %1 src\backend\bootstrap\bootparse.c
src\backend\bootstrap\bootstrap_tokens.h
  if "%1" == "src\pl\plpgsql\src\gram.y" call :generate %1 src\pl\plpgsql\src\pl_gram.c src\pl\plpgsql\src\pl.tab.h
  if "%1" == "src\interfaces\ecpg\preproc\preproc.y" call :generate %1 src\interfaces\ecpg\preproc\preproc.c
src\interfaces\ecpg\preproc\preproc.h

Re: Compile error with MSVC

From
Magnus Hagander
Date:
Yoshiyuki Asaba wrote:
> Hi,
>
> I tried to compile using Visual C++ 2005. But I got the following
> errors.
>
>   .\src\backend\parser\keywords.c(22) : fatal error C1083: 'parser/parse.h': No such file or directory
>
> I saw src/tools/msvc/pgbison.bat. Why does it copy
> src/backend/parser/parser.h to src/include/parser directory?

<snip>
While your solution may be correct (I don't recall offhand how, but it
doesn't seem off the chart), I don't see how it can help you in this
case. Since pgbison would copy the file there, ISTM that pgbison must
have filed. Did you not get a warning output from that one earlier in
your build?

//Magnus



Re: Compile error with MSVC

From
Yoshiyuki Asaba
Date:
Hi,

From: Magnus Hagander <magnus@hagander.net>
Subject: Re: [PATCHES] Compile error with MSVC
Date: Thu, 05 Jul 2007 07:03:11 +0200

> > I tried to compile using Visual C++ 2005. But I got the following
> > errors.
> >
> >   .\src\backend\parser\keywords.c(22) : fatal error C1083: 'parser/parse.h': No such file or directory
> >
> > I saw src/tools/msvc/pgbison.bat. Why does it copy
> > src/backend/parser/parser.h to src/include/parser directory?
>
> <snip>
> While your solution may be correct (I don't recall offhand how, but it
> doesn't seem off the chart), I don't see how it can help you in this
> case. Since pgbison would copy the file there, ISTM that pgbison must
> have filed. Did you not get a warning output from that one earlier in
> your build?

If gram.c is older than gram.y, pgbison copy parse.h by custom build
step. But it is newer, pgbison is skipped.

I see the same problem in PostgreSQL 8.2.4. parse.h does not exist in
"src/include/parser" directory.

  % tar ztvf postgresql-8.2.4.tar.gz | grep -w parse.h
  -rw-r--r-- pgsql/pgsql   16540 2007-04-20 14:13  postgresql-8.2.4/src/backend/parser/parse.h

gram.c is newer than gram.y in PostgreSQL 8.2.4.

  % tar ztvf postgresql-8.2.4.tar.gz | grep -w gram.\[cy\] | grep -v plpgsql
  -rw-r--r-- pgsql/pgsql  237506 2006-11-06 07:42 postgresql-8.2.4/src/backend/parser/gram.y
  -rw-r--r-- pgsql/pgsql 1040559 2007-04-20 14:13 postgresql-8.2.4/src/backend/parser/gram.c

--
Yoshiyuki Asaba
y-asaba@sraoss.co.jp

Re: Compile error with MSVC

From
Magnus Hagander
Date:
Yoshiyuki Asaba wrote:
> Hi,
>
> From: Magnus Hagander <magnus@hagander.net>
> Subject: Re: [PATCHES] Compile error with MSVC
> Date: Thu, 05 Jul 2007 07:03:11 +0200
>
>>> I tried to compile using Visual C++ 2005. But I got the following
>>> errors.
>>>
>>>   .\src\backend\parser\keywords.c(22) : fatal error C1083: 'parser/parse.h': No such file or directory
>>>
>>> I saw src/tools/msvc/pgbison.bat. Why does it copy
>>> src/backend/parser/parser.h to src/include/parser directory?
>> <snip>
>> While your solution may be correct (I don't recall offhand how, but it
>> doesn't seem off the chart), I don't see how it can help you in this
>> case. Since pgbison would copy the file there, ISTM that pgbison must
>> have filed. Did you not get a warning output from that one earlier in
>> your build?
>
> If gram.c is older than gram.y, pgbison copy parse.h by custom build
> step. But it is newer, pgbison is skipped.
>
> I see the same problem in PostgreSQL 8.2.4. parse.h does not exist in
> "src/include/parser" directory.

Oh, I see, you're building from the tarball, not from cvs. Now I see the
problem. And yeah, your solution looks like the correct one. I'll take a
look at the details and make sure it gets in there.

//Magnus

Re: Compile error with MSVC

From
Alvaro Herrera
Date:
Magnus Hagander wrote:
> Yoshiyuki Asaba wrote:
> > Hi,
> >
> > From: Magnus Hagander <magnus@hagander.net>
> > Subject: Re: [PATCHES] Compile error with MSVC
> > Date: Thu, 05 Jul 2007 07:03:11 +0200
> >
> >>> I tried to compile using Visual C++ 2005. But I got the following
> >>> errors.
> >>>
> >>>   .\src\backend\parser\keywords.c(22) : fatal error C1083: 'parser/parse.h': No such file or directory
> >>>
> >>> I saw src/tools/msvc/pgbison.bat. Why does it copy
> >>> src/backend/parser/parser.h to src/include/parser directory?
> >> <snip>
> >> While your solution may be correct (I don't recall offhand how, but it
> >> doesn't seem off the chart), I don't see how it can help you in this
> >> case. Since pgbison would copy the file there, ISTM that pgbison must
> >> have filed. Did you not get a warning output from that one earlier in
> >> your build?
> >
> > If gram.c is older than gram.y, pgbison copy parse.h by custom build
> > step. But it is newer, pgbison is skipped.
> >
> > I see the same problem in PostgreSQL 8.2.4. parse.h does not exist in
> > "src/include/parser" directory.
>
> Oh, I see, you're building from the tarball, not from cvs. Now I see the
> problem. And yeah, your solution looks like the correct one. I'll take a
> look at the details and make sure it gets in there.

Maybe what needs fixed is that the Makefile ought to copy the parse.h
file to the include dir.  Using src/backend/parser as an include dir
strikes me as a bad idea.

--
Alvaro Herrera                 http://www.amazon.com/gp/registry/CTMLCN8V17R4
"Nunca se desea ardientemente lo que solo se desea por razón" (F. Alexandre)

Re: Compile error with MSVC

From
Magnus Hagander
Date:
Alvaro Herrera wrote:
> Magnus Hagander wrote:
>> Yoshiyuki Asaba wrote:
>>> Hi,
>>>
>>> From: Magnus Hagander <magnus@hagander.net>
>>> Subject: Re: [PATCHES] Compile error with MSVC
>>> Date: Thu, 05 Jul 2007 07:03:11 +0200
>>>
>>>>> I tried to compile using Visual C++ 2005. But I got the following
>>>>> errors.
>>>>>
>>>>>   .\src\backend\parser\keywords.c(22) : fatal error C1083: 'parser/parse.h': No such file or directory
>>>>>
>>>>> I saw src/tools/msvc/pgbison.bat. Why does it copy
>>>>> src/backend/parser/parser.h to src/include/parser directory?
>>>> <snip>
>>>> While your solution may be correct (I don't recall offhand how, but it
>>>> doesn't seem off the chart), I don't see how it can help you in this
>>>> case. Since pgbison would copy the file there, ISTM that pgbison must
>>>> have filed. Did you not get a warning output from that one earlier in
>>>> your build?
>>> If gram.c is older than gram.y, pgbison copy parse.h by custom build
>>> step. But it is newer, pgbison is skipped.
>>>
>>> I see the same problem in PostgreSQL 8.2.4. parse.h does not exist in
>>> "src/include/parser" directory.
>> Oh, I see, you're building from the tarball, not from cvs. Now I see the
>> problem. And yeah, your solution looks like the correct one. I'll take a
>> look at the details and make sure it gets in there.
>
> Maybe what needs fixed is that the Makefile ought to copy the parse.h
> file to the include dir.  Using src/backend/parser as an include dir
> strikes me as a bad idea.

Well, the MSVC build is just emulating Unix regardless of if it's good
or bad :-)

Anyway. I'm not sure it matters enough to change it on Unix... It's not
like it hasn't worked well for many years ;-)

//Magnus

Re: Compile error with MSVC

From
Magnus Hagander
Date:
Magnus Hagander wrote:
> Alvaro Herrera wrote:
>> Magnus Hagander wrote:
>>> Yoshiyuki Asaba wrote:
>>>> Hi,
>>>>
>>>> From: Magnus Hagander <magnus@hagander.net>
>>>> Subject: Re: [PATCHES] Compile error with MSVC
>>>> Date: Thu, 05 Jul 2007 07:03:11 +0200
>>>>
>>>>>> I tried to compile using Visual C++ 2005. But I got the following
>>>>>> errors.
>>>>>>
>>>>>>   .\src\backend\parser\keywords.c(22) : fatal error C1083: 'parser/parse.h': No such file or directory
>>>>>>
>>>>>> I saw src/tools/msvc/pgbison.bat. Why does it copy
>>>>>> src/backend/parser/parser.h to src/include/parser directory?
>>>>> <snip>
>>>>> While your solution may be correct (I don't recall offhand how, but it
>>>>> doesn't seem off the chart), I don't see how it can help you in this
>>>>> case. Since pgbison would copy the file there, ISTM that pgbison must
>>>>> have filed. Did you not get a warning output from that one earlier in
>>>>> your build?
>>>> If gram.c is older than gram.y, pgbison copy parse.h by custom build
>>>> step. But it is newer, pgbison is skipped.
>>>>
>>>> I see the same problem in PostgreSQL 8.2.4. parse.h does not exist in
>>>> "src/include/parser" directory.
>>> Oh, I see, you're building from the tarball, not from cvs. Now I see the
>>> problem. And yeah, your solution looks like the correct one. I'll take a
>>> look at the details and make sure it gets in there.
>> Maybe what needs fixed is that the Makefile ought to copy the parse.h
>> file to the include dir.  Using src/backend/parser as an include dir
>> strikes me as a bad idea.
>
> Well, the MSVC build is just emulating Unix regardless of if it's good
> or bad :-)
>
> Anyway. I'm not sure it matters enough to change it on Unix... It's not
> like it hasn't worked well for many years ;-)

I've applied this. I didn't include your changes to clean.bat, because
clean really should clean up everything ;-) This should fix building for
people working off dev snapshot tarballs.

(If we want to change where parse.h is supposed to live, we'll take that
as a separate step)

Thanks!

//Magnus

Re: Compile error with MSVC

From
Alvaro Herrera
Date:
Magnus Hagander wrote:

> > Anyway. I'm not sure it matters enough to change it on Unix... It's not
> > like it hasn't worked well for many years ;-)
>
> I've applied this. I didn't include your changes to clean.bat, because
> clean really should clean up everything ;-) This should fix building for
> people working off dev snapshot tarballs.
>
> (If we want to change where parse.h is supposed to live, we'll take that
> as a separate step)

I noticed that what the Makefile do is symlink parse.h into the include
dir.  So it doesn't need to add a -Isrc/backend/parser.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support