how to link an external lib on Windows

Started by chaoyong wangabout 16 years ago2 messageshackers
Jump to latest
#1chaoyong wang
catcher_wang@hotmail.com

Hi,
I build PG on VS2005, which files should I change to use a external lib in my own contrib, for example, Berkeley DB 4.8.26?

Until now, I have tried the following 2 ways, but both failed.

1. Add the target include and lib
1). src/tools/msvc/config.pl
add a new line: db48=>'C:\Program Files\Oracle\Berkeley DB 4.8.26'
2). src/Makefile.global.in

Add a new line after line 435 "LIBS := -lpgport $(LIBS)" (maybe not
exactly same with different versions): LIBS := -ldb48 $(LIBS)
3). contrib/mycontrib/Makefile
SHLIB_LINK += $(filter -ldb48, ($LIBS))
Then I build DEBUG in Visual Studio 2005 Command Prompt, it reports db.h not found.

2. The first error report shows that the include file is not accessed

I changed the congiture option "--with-libxml" to yes, and add the
files of include and lib under Berkeley DB 4.8.26 to libxml folder.
When I build, it reports: fatal error LNK1120: 2 unresolved externals

Then I check the single project on VS2005, there is no libdb48.lib in
the Linker input, after I added BDB_DIR\lib\libdb48.lib to it. It build
successfully.

But I want to build the whole PG source with mycontrib, Had someone ever encounter a problem like this? Thanks~

Best Regards
Chaoyong Wang

_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
https://signup.live.com/signup.aspx?id=60969

#2Magnus Hagander
magnus@hagander.net
In reply to: chaoyong wang (#1)
Re: how to link an external lib on Windows

2010/3/22 chaoyong wang <catcher_wang@hotmail.com>

Hi,
I build PG on VS2005, which files should I change to use a external lib
in my own contrib, for example, Berkeley DB 4.8.26?

Until now, I have tried the following 2 ways, but both failed.

1. Add the target include and lib
1). src/tools/msvc/config.pl
add a new line: db48=>'C:\Program Files\Oracle\Berkeley DB
4.8.26'
2). src/Makefile.global.in
Add a new line after line 435 "LIBS := -lpgport $(LIBS)" (maybe
not exactly same with different versions): LIBS := -ldb48 $(LIBS)
3). contrib/mycontrib/Makefile
SHLIB_LINK += $(filter -ldb48, ($LIBS))
Then I build DEBUG in Visual Studio 2005 Command Prompt, it reports
db.h not found.

2. The first error report shows that the include file is not accessed
I changed the congiture option "--with-libxml" to yes, and add the
files of include and lib under Berkeley DB 4.8.26 to libxml folder.
When I build, it reports: fatal error LNK1120: 2 unresolved
externals
Then I check the single project on VS2005, there is no libdb48.lib
in the Linker input, after I added BDB_DIR\lib\libdb48.lib to it. It build
successfully.

But I want to build the whole PG source with mycontrib, Had someone
ever encounter a problem like this? Thanks~

Makefile and Makefile.global aren't used when building with MSVC. You

probably want to edit src/tools/msvc/Mkvcbuild.pm, specifically you are
probably looking for $contrib_extrainclude and $contrib_extralibs.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/