Thread: pginterface compiling

pginterface compiling

From
"Jose' Soares Da Silva"
Date:
Hi, all

I have this message when I try to compile pginterface...
Please help...

$ make all
cc -c -g -Wall -I/usr/local/pgsql/include  pginterface.c halt.c
cc -g -Wall -I/usr/local/pgsql/include   -L/usr/local/pgsql/lib -lpq     -o .c
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x5a): undefined reference to `main'
make: *** [.c] Error 1
verde:~/pgsql/contrib/pginterface$
                                                          Jose'


Re: [QUESTIONS] pginterface compiling

From
"Oliver Elphick"
Date:
"Jose' Soares Da Silva" wrote:
  >Hi, all
  >
  >I have this message when I try to compile pginterface...
  >Please help...
  >
  >$ make all
  >cc -c -g -Wall -I/usr/local/pgsql/include  pginterface.c halt.c
  >cc -g -Wall -I/usr/local/pgsql/include   -L/usr/local/pgsql/lib -lpq     -o
      >.c
  >/usr/lib/crt1.o: In function `_start':
  >/usr/lib/crt1.o(.text+0x5a): undefined reference to `main'
  >make: *** [.c] Error 1

Well, you don't seem to have specified any files to link.  The second
cc command says to create an executable called `.c' but doesn't specify
and files to compile or link, except the libpq library.  So naturally, cc
cannot find a main() routine; that is what it is complaining about.

Ah, I see it's not your fault but the Makefile's...

I guess you are using GNU make, as I am.  This works for me:

=======================================================
#
# Makefile for GNU make
#
#
PGINTERFACE = pginterface.o halt.o
TARGET = pginsert pgwordcount pgnulltest
CFLAGS = -g -Wall -I/usr/local/pgsql/include -I.
LDFLAGS = -L/usr/local/pgsql/lib -lpq

all : $(TARGET)

$(TARGET): %:   %.o ${PGINTERFACE}
        $(CC) -o $@ $(CFLAGS) $@.c ${PGINTERFACE} $(LDFLAGS)

clean:
        rm -f *.o $(TARGET) log core

install:
        make clean
        make CFLAGS=-O
        install -s -o bin -g bin $(TARGET) /usr/local/bin
=======================================================



--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver

PGP key from public servers; key ID 32B8FAA1

                 ========================================
    Come to me, all you who labour and are heavily laden, and I will
    give you rest. Take my yoke upon you, and learn from me; for I am
    meek and lowly in heart, and you shall find rest for your souls.
    For my yoke is easy and my burden is light.    (Matthew 11: 28-30)



Re: [HACKERS] pginterface compiling

From
Bruce Momjian
Date:
>
> Hi, all
>
> I have this message when I try to compile pginterface...
> Please help...
>
> $ make all
> cc -c -g -Wall -I/usr/local/pgsql/include  pginterface.c halt.c
> cc -g -Wall -I/usr/local/pgsql/include   -L/usr/local/pgsql/lib -lpq     -o .c
> /usr/lib/crt1.o: In function `_start':
> /usr/lib/crt1.o(.text+0x5a): undefined reference to `main'
> make: *** [.c] Error 1
> verde:~/pgsql/contrib/pginterface$
>                                                           Jose'

Someone has been playing with the Makefile.  Basically it is complaining
because you have only specified libraries in the compile line.  You need
a function to call the pginterface, with a main.  Try one of the sample
*.c files.

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)