Is there any autoconf guru?

I have lots problems Autoconf + C++ library.

if I make CC=CXX, configure can't find libpq,
 AC_CHECK_LIB(pq, PQexec)

because it try link PQexec() - and it is missing 

if I keep CC as cc 
AC_TRY_COMPILE([#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
],
[int a = accept(1, (struct sockaddr *) 0, (int *) 0);],
[AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)],
[AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)])

return wrong result because int always aceptable for C but
can cause error for CXX

Is there autoconf version modified for work with C++ or 
I have to patch it's macros by my self ?


---
Dmitry Samersoff, dms@wplus.net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...

Thu, 29 Jul 1999 16:04:11 +0400 (MSD)
Dmitry Samersoff <dms@wplus.net>
Off-topic: autoconf guru

If you check configure.in with PostgreSQL, we use the --with-libs call in
order to tell it where to look for 'libraries outside the system
norm'...check the code for that, as I believe its what you are looking
for, since, in general, the libpq would be outside that 'norm'..


 On Thu, 29 Jul 1999, Dmitry Samersoff wrote:

> Is there any autoconf guru?
> 
> I have lots problems Autoconf + C++ library.
> 
> if I make CC=CXX, configure can't find libpq,
>  AC_CHECK_LIB(pq, PQexec)
> 
> because it try link PQexec() - and it is missing 
> 
> if I keep CC as cc 
> AC_TRY_COMPILE([#include <stdlib.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> ],
> [int a = accept(1, (struct sockaddr *) 0, (int *) 0);],
> [AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)],
> [AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)])
> 
> return wrong result because int always aceptable for C but
> can cause error for CXX
> 
> Is there autoconf version modified for work with C++ or 
> I have to patch it's macros by my self ?
> 
> 
> ---
> Dmitry Samersoff, dms@wplus.net, ICQ:3161705
> http://devnull.wplus.net
> * There will come soft rains ...
> 

Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
Systems Administrator @ hub.org 
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org 


Thu, 29 Jul 1999 09:52:49 -0300 (ADT)
The Hermit Hacker <scrappy@hub.org>
Re: [HACKERS] Off-topic: autoconf guru

On 29-Jul-99 The Hermit Hacker wrote:
> 
> If you check configure.in with PostgreSQL, we use the --with-libs call in
> order to tell it where to look for 'libraries outside the system
> norm'...check the code for that, as I believe its what you are looking
> for, since, in general, the libpq would be outside that 'norm'..

Thanks, but I mention some other problem - 
sequence 
 CC=g++
 AC_CHECK_LIB(pq, PQexec)

is espanded by autoconf into
... main(){ PQexec(); } ...
that can't be compiled by g++, 
instead 
... main(){ PGconn *conn; const char *query; PQexec(conn,query); }   
 
is there a way to correct this problem or I need to rewrite 
autoconf macros?

configure:2672: checking for PQexec in -lpq
configure:2691: g++ -o conftest -g -O2   conftest.c -lpq 
-L/usr/local/pgsql/lib  1>&5
configure:2688: Undefined symbol `PQexec(void)' referenced from text segment
collect2: ld returned 1 exit status
configure: failed program was:
#line 2680 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char PQexec();

int main() {
PQexec()
; return 0; }


> 
> 
>  On Thu, 29 Jul 1999, Dmitry Samersoff wrote:
> 
>> Is there any autoconf guru?
>> 
>> I have lots problems Autoconf + C++ library.
>> 
>> if I make CC=CXX, configure can't find libpq,
>>  AC_CHECK_LIB(pq, PQexec)
>> 
>> because it try link PQexec() - and it is missing 
>> 
>> if I keep CC as cc 
>> AC_TRY_COMPILE([#include <stdlib.h>
>> #include <sys/types.h>
>> #include <sys/socket.h>
>> ],
>> [int a = accept(1, (struct sockaddr *) 0, (int *) 0);],
>> [AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)],
>> [AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)])
>> 
>> return wrong result because int always aceptable for C but
>> can cause error for CXX
>> 
>> Is there autoconf version modified for work with C++ or 
>> I have to patch it's macros by my self ?
>> 
>> 
>> ---
>> Dmitry Samersoff, dms@wplus.net, ICQ:3161705
>> http://devnull.wplus.net
>> * There will come soft rains ...
>> 
> 
> Marc G. Fournier                   ICQ#7615664               IRC Nick:
> Scrappy
> Systems Administrator @ hub.org 
> primary: scrappy@hub.org           secondary:
> scrappy@{freebsd|postgresql}.org 

---
Dmitry Samersoff, dms@wplus.net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...

Thu, 29 Jul 1999 18:02:36 +0400 (MSD)
Dmitry Samersoff <dms@wplus.net>
Re: [HACKERS] Off-topic: autoconf guru
Dmitry Samersoff <dms@wplus.net> writes:
> if I make CC=CXX, configure can't find libpq,

You shouldn't do that.  CC is supposed to be a C compiler not a C++
compiler.

We have enough cross-platform headaches with the code already ...
trying to make it all compile under C++ as well as C is a pushup
I don't care to undertake...

> if I keep CC as cc 
> AC_TRY_COMPILE([#include <stdlib.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> ],
> [int a = accept(1, (struct sockaddr *) 0, (int *) 0);],
> [AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)],
> [AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)])

> return wrong result because int always aceptable for C but
> can cause error for CXX

Huh?  How can it be a problem for C++?  The test snippet is C, and
so is the code that is going to be trying to call accept().

> Is there autoconf version modified for work with C++ or 
> I have to patch it's macros by my self ?

I think you have a misconfigured C++ installation, and that you'd
be best off directing your attention to fixing that.  I have
seen libpq++ fail in odd ways when I tried to build Postgres here
with a fresh egcs install whose C++ support wasn't right.  (IIRC,
my problem was that /usr/local/lib/libg++ was an old version not
compatible with the new egcs --- but the error messages weren't
particularly helpful in diagnosing that...)

			regards, tom lane

Thu, 29 Jul 1999 10:37:39 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] Off-topic: autoconf guru 
Hi Dmitry,

Autoconf can do this out of the box. With the macros AC_LANG_C and 
AC_LANG_CPLUSPLUS you can switch between C and C++ compiler mode. Here 
is a small example based on the snippet you provided:


	AC_PREREQ(2.12)
	AC_INIT(configure.in)

	#
	#  Check which C and C++ compiler to use
	#
	AC_PROG_CC
	AC_PROG_CXX

	#
	#  The following checks are done with the C compiler
	#
	AC_LANG_C

	AC_CHECK_FUNC(accept)


	#
	#  Now switch over to the C++ compiler for the next test
	#
	AC_LANG_CPLUSPLUS

	AC_MSG_CHECKING(socket size type)
	AC_TRY_COMPILE([#include <stdlib.h>
	#include <sys/types.h>
	#include <sys/socket.h>
	],
	[int a = accept(1, (struct sockaddr *) 0, (int *) 0);],
	[AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)],
	[AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)])

	#
	#  Switch back to C mode again
	#
	AC_LANG_C

	AC_OUTPUT()    


Best regards,

Patrick
-- 
Patrick van Kleef	  	
pkleef@roady.xs4all.nl



Thu, 29 Jul 1999 16:59:43 +0200
Patrick van Kleef <pvk@pobox.com>
Re: [HACKERS] Off-topic: autoconf guru 
Dmitry Samersoff <dms@wplus.net> writes:
>  CC=g++

That is your problem.  Don't do it.

Autoconf's job is difficult enough without trying to make all its macros
work with either C or C++ compilers.  They haven't tried.  If you think
it is critical that they should try, go off and join the GNU autoconf
team.

Back to actually solving the problem: you should be letting CC=gcc and
CXX=g++ as the system is expecting.  I don't know what problem you are
trying to solve, but I can assure you that switching those two symbols
around is *not* the path to a solution.  What happens when you try to
build the system without forcing the wrong choice of compilers?

			regards, tom lane

Thu, 29 Jul 1999 11:20:46 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] Off-topic: autoconf guru 

On 29-Jul-99 Patrick van Kleef wrote:
> Hi Dmitry,
> 
> Autoconf can do this out of the box. With the macros AC_LANG_C and 
> AC_LANG_CPLUSPLUS you can switch between C and C++ compiler mode. Here 
> is a small example based on the snippet you provided:

Thank you very match !!!!
It is exactly what I need for !!!

> 
> 
>       AC_PREREQ(2.12)
>       AC_INIT(configure.in)
> 
>       #
>       #  Check which C and C++ compiler to use
>       #
>       AC_PROG_CC
>       AC_PROG_CXX
> 
>       #
>       #  The following checks are done with the C compiler
>       #
>       AC_LANG_C
> 
>       AC_CHECK_FUNC(accept)
> 
> 
>       #
>       #  Now switch over to the C++ compiler for the next test
>       #
>       AC_LANG_CPLUSPLUS
> 
>       AC_MSG_CHECKING(socket size type)
>       AC_TRY_COMPILE([#include <stdlib.h>
>       #include <sys/types.h>
>       #include <sys/socket.h>
>       ],
>       [int a = accept(1, (struct sockaddr *) 0, (int *) 0);],
>       [AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)],
>       [AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)])
> 
>       #
>       #  Switch back to C mode again
>       #
>       AC_LANG_C
> 
>       AC_OUTPUT()    
> 
> 
> Best regards,
> 
> Patrick
> -- 
> Patrick van Kleef             
> pkleef@roady.xs4all.nl

---
Dmitry Samersoff, dms@wplus.net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...

Thu, 29 Jul 1999 19:52:00 +0400 (MSD)
Dmitry Samersoff <dms@wplus.net>
Re: [HACKERS] Off-topic: autoconf guru