Skip site navigation (1) Skip section navigation (2)

Problem with Win32 pg_dump linking and symbols

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Cc: PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgreSQL(dot)org>
Subject: Problem with Win32 pg_dump linking and symbols
Date: 2004-10-05 16:35:15
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-hackers-win32
As some of you know, in the past few days I have tightened up the use of
libpgport so it is less prone to breakage from code changes.   However,
in the cleanup, I found an unusual problem with linking pg_dump on
Win32.  If I build pg_dump linking in libpgport and libpq, I get a
failure due to a duplicate symbol in both libraries:

	gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -O1 -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align pg_dump.o common.o pg_dump_sort.o pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o pg_backup_files.o pg_backup_null.o pg_backup_tar.o dumputils.o ../../../src/backend/parser/keywords.o -L../../../src/interfaces/libpq -lpq -L../../../src/port   -O1 -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align -lpgport -lwsock32 -lm  -lws2_32 -o pg_dump.exe
	../../../src/port/libpgport.a(pgstrcasecmp.o)(.text+0x2aa):pgstrcasecmp.c: multiple definition of `pg_tolower'
	../../../src/interfaces/libpq/libpq.a(ds00154.o)(.text+0x0): first defined here
	make: *** [pg_dump] Error 1

I have temporarily fixed this by adding a few lines to the pg_dump
makefile that explicitly link in port/exec.o:
	# not sure why MinGW needs this but it prevents a link failure
	ifeq ($(PORTNAME), win32)
	EXTRA_OBJS += $(top_builddir)/src/port/exec.o

port/exec.o was used in previous build but shouldn't be needed anymore
because a client-level build is already in libpgport.

The error report is right that the symbol exists in both libraries, but
psql also uses items from pgstrcasecmp.c (pg_tolower) and exec.c but
builds fine without using exec.o directly on the link line:

	gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -O1 -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align command.o common.o help.o input.o stringutils.o mainloop.o copy.o startup.o prompt.o variables.o large_obj.o print.o describe.o psqlscan.o tab-complete.o mbprint.o -L../../../src/interfaces/libpq -lpq -L../../../src/port   -O1 -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align -lpgport -lwsock32 -lm  -lws2_32 -o psql.exe

Any ideas on why this is happening?  What are the rules for Win32
linkage?  Doesn't it take the first matching library symbol?  Can people
reproduce this failure?  Why is pg_dump different from psql linkage?

  Bruce Momjian                        |
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-hackers by date

Next:From: Abhijit Menon-SenDate: 2004-10-05 16:59:41
Subject: Re: libpq and prepared statements progress for 8.0
Previous:From: Stefan KaltenbrunnerDate: 2004-10-05 16:27:43
Subject: Re: -HEAD build failure on OpenBSD 3.6-current/Sparc64

pgsql-hackers-win32 by date

Next:From: Reini UrbanDate: 2004-10-05 17:45:50
Subject: win32 tablespace handing
Previous:From: Reini UrbanDate: 2004-10-04 21:25:35
Subject: Re: open item: tablespace handing in pg_dump/pg_restore

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group