Linking against static libpq using Visual C++
Dear PostgreSQL community,
When trying to compile c++ code including libpq against the static
version libpq.lib, Visual Studio 2010 gives me the following errors:
1>main.obj : error LNK2019: Unresolved external reference "__imp__exit"
in Funktion "_main".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"__imp__exit".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"__imp__exit".
1>main.obj : error LNK2019: Unresolved external reference
"__imp__fprintf" in Funktion "_main".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"__imp____iob_func".
1>libpq.lib(win32error.obj) : error LNK2001: Unresolved external symbol
"__imp____iob_func".
1>main.obj : error LNK2019: Unresolved external reference
"__imp____iob_func" in Funktion "_main".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"__imp____iob_func".
1>libpq.lib(encnames.obj) : error LNK2001: Unresolved external symbol
"__imp____iob_func".
1>libpq.lib(snprintf.obj) : error LNK2001: Unresolved external symbol
"__imp____iob_func".
1>main.obj : error LNK2019: Unresolved external reference
"@_RTC_CheckStackVars@8" in Funktion "_main".
1>main.obj : error LNK2019: Unresolved external reference
"__RTC_CheckEsp" in Funktion "_main".
1>main.obj : error LNK2001: Unresolved external symbol "__RTC_Shutdown".
1>main.obj : error LNK2001: Unresolved external symbol "__RTC_InitBase".
1>LINK : error LNK2001: Unresolved external symbol "_mainCRTStartup".
1>libpq.lib(md5.obj) : error LNK2019: Unresolved external reference
"__imp__free" in Funktion "_pg_md5_hash".
1>libpq.lib(dirent.obj) : error LNK2001: Unresolved external symbol
"__imp__free".
1>libpq.lib(fe-protocol3.obj) : error LNK2001: Unresolved external
symbol "__imp__free".
1>libpq.lib(fe-auth.obj) : error LNK2001: Unresolved external symbol
"__imp__free".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"__imp__free".
1>libpq.lib(getaddrinfo.obj) : error LNK2001: Unresolved external symbol
"__imp__free".
1>libpq.lib(fe-exec.obj) : error LNK2001: Unresolved external symbol
"__imp__free".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"__imp__free".
1>libpq.lib(pqexpbuffer.obj) : error LNK2001: Unresolved external symbol
"__imp__free".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "__imp__free".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"__imp__strdup".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"__imp__strdup" in Funktion "_dupEvents".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"__imp__strdup".
1>libpq.lib(fe-protocol3.obj) : error LNK2001: Unresolved external
symbol "__imp__strdup".
1>libpq.lib(fe-auth.obj) : error LNK2001: Unresolved external symbol
"__imp__strdup".
1>libpq.lib(getaddrinfo.obj) : error LNK2019: Unresolved external
reference "__imp__malloc" in Funktion "_pg_getaddrinfo".
1>libpq.lib(md5.obj) : error LNK2001: Unresolved external symbol
"__imp__malloc".
1>libpq.lib(dirent.obj) : error LNK2001: Unresolved external symbol
"__imp__malloc".
1>libpq.lib(fe-protocol3.obj) : error LNK2001: Unresolved external
symbol "__imp__malloc".
1>libpq.lib(pthread-win32.obj) : error LNK2001: Unresolved external
symbol "__imp__malloc".
1>libpq.lib(fe-auth.obj) : error LNK2001: Unresolved external symbol
"__imp__malloc".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"__imp__malloc".
1>libpq.lib(fe-exec.obj) : error LNK2001: Unresolved external symbol
"__imp__malloc".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"__imp__malloc".
1>libpq.lib(pqexpbuffer.obj) : error LNK2001: Unresolved external symbol
"__imp__malloc".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "__imp__malloc".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"__imp__realloc" in Funktion "_pqAddTuple".
1>libpq.lib(pqexpbuffer.obj) : error LNK2001: Unresolved external symbol
"__imp__realloc".
1>libpq.lib(fe-misc.obj) : error LNK2001: Unresolved external symbol
"__imp__realloc".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"__imp__realloc".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"__imp__sscanf" in Funktion "_pqSaveParameterStatus".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"__imp__strncpy" in Funktion "_PQoidStatus".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "__imp__strncpy".
1>libpq.lib(fe-protocol3.obj) : error LNK2001: Unresolved external
symbol "__imp__strncpy".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"__imp__strspn" in Funktion "_PQoidStatus".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"__imp__strncmp" in Funktion "_PQoidStatus".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"__imp__strncmp".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "__imp__strncmp".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"__imp__strtoul" in Funktion "_PQoidValue".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(getaddrinfo.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(md5.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(dirent.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(fe-misc.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "___security_cookie".
1>libpq.lib(ip.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(fe-auth.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"___security_cookie" in Funktion "_pqInternalNotice".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(encnames.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(snprintf.obj) : error LNK2001: Unresolved external symbol
"___security_cookie".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(getaddrinfo.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(md5.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(dirent.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(fe-misc.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "@__security_check_cookie@4".
1>libpq.lib(ip.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(fe-auth.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"@__security_check_cookie@4" in Funktion "_pqInternalNotice".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(encnames.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(snprintf.obj) : error LNK2001: Unresolved external symbol
"@__security_check_cookie@4".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"__imp__isdigit" in Funktion "_PQcmdTuples".
1>libpq.lib(inet_aton.obj) : error LNK2001: Unresolved external symbol
"__imp__isdigit".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "_memcpy".
1>libpq.lib(fe-protocol3.obj) : error LNK2001: Unresolved external
symbol "_memcpy".
1>libpq.lib(getaddrinfo.obj) : error LNK2001: Unresolved external symbol
"_memcpy".
1>libpq.lib(md5.obj) : error LNK2001: Unresolved external symbol "_memcpy".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"_memcpy" in Funktion "_PQsetResultAttrs".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"_memcpy".
1>libpq.lib(pqexpbuffer.obj) : error LNK2001: Unresolved external symbol
"_memcpy".
1>libpq.lib(fe-misc.obj) : error LNK2001: Unresolved external symbol
"_memcpy".
1>libpq.lib(fe-protocol3.obj) : error LNK2001: Unresolved external
symbol "_memset".
1>libpq.lib(md5.obj) : error LNK2001: Unresolved external symbol "_memset".
1>libpq.lib(fe-exec.obj) : error LNK2019: Unresolved external reference
"_memset" in Funktion "_PQsetvalue".
1>libpq.lib(fe-connect.obj) : error LNK2001: Unresolved external symbol
"_memset".
1>libpq.lib(snprintf.obj) : error LNK2001: Unresolved external symbol
"_memset".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "_memset".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp___time64" in Funktion "_time".
1>libpq.lib(fe-misc.obj) : error LNK2001: Unresolved external symbol
"__imp___time64".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__DeleteSecurityContext@4" in Funktion "_closePGconn".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__FreeCredentialsHandle@4" in Funktion "_closePGconn".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__strncat" in Funktion "_internal_cancel".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__fflush" in Funktion "_PQuntrace".
1>libpq.lib(fe-misc.obj) : error LNK2001: Unresolved external symbol
"__imp__fflush".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__fclose" in Funktion "_parseServiceInfo".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__strchr" in Funktion "_parseServiceInfo".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "__imp__strchr".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"__imp__strchr".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__isspace" in Funktion "_parseServiceInfo".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "__imp__isspace".
1>libpq.lib(inet_aton.obj) : error LNK2001: Unresolved external symbol
"__imp__isspace".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__fgets" in Funktion "_parseServiceInfo".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__fopen" in Funktion "_parseServiceInfo".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__getenv" in Funktion "_parseServiceInfo".
1>libpq.lib(fe-misc.obj) : error LNK2001: Unresolved external symbol
"__imp__getenv".
1>libpq.lib(fe-protocol2.obj) : error LNK2001: Unresolved external
symbol "__imp__getenv".
1>libpq.lib(fe-protocol3.obj) : error LNK2001: Unresolved external
symbol "__imp__getenv".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__ferror" in Funktion "_PasswordFromFile".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__feof" in Funktion "_PasswordFromFile".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__isalpha" in Funktion "_PasswordFromFile".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__atoi" in Funktion "_connectDBStart".
1>libpq.lib(fe-protocol3.obj) : error LNK2001: Unresolved external
symbol "__imp__atoi".
1>libpq.lib(getaddrinfo.obj) : error LNK2001: Unresolved external symbol
"__imp__atoi".
1>libpq.lib(encnames.obj) : error LNK2019: Unresolved external reference
"__imp__isalnum" in Funktion "_clean_encoding_name".
1>libpq.lib(snprintf.obj) : error LNK2019: Unresolved external reference
"__imp__fwrite" in Funktion "_flushbuffer".
1>libpq.lib(snprintf.obj) : error LNK2019: Unresolved external reference
"__imp__memmove" in Funktion "_dostr".
1>libpq.lib(fe-misc.obj) : error LNK2001: Unresolved external symbol
"__imp__memmove".
1>libpq.lib(snprintf.obj) : error LNK2019: Unresolved external reference
"__imp__sprintf" in Funktion "_fmtptr".
1>libpq.lib(snprintf.obj) : error LNK2019: Unresolved external reference
"__aulldvrm" in Funktion "_fmtint".
1>libpq.lib(snprintf.obj) : error LNK2001: Unresolved external symbol
"__fltused".
1>libpq.lib(snprintf.obj) : error LNK2019: Unresolved external reference
"__imp___errno" in Funktion "_pg_vsnprintf".
1>libpq.lib(dirmod.obj) : error LNK2001: Unresolved external symbol
"__imp___errno".
1>libpq.lib(win32error.obj) : error LNK2001: Unresolved external symbol
"__imp___errno".
1>libpq.lib(dirent.obj) : error LNK2001: Unresolved external symbol
"__imp___errno".
1>libpq.lib(fe-misc.obj) : error LNK2019: Unresolved external reference
"__imp__fputc" in Funktion "_fputnbytes".
1>libpq.lib(fe-protocol2.obj) : error LNK2019: Unresolved external
reference "__imp__strstr" in Funktion "_pqGetErrorNotice2".
1>libpq.lib(pgstrcasecmp.obj) : error LNK2019: Unresolved external
reference "__imp__tolower" in Funktion "_pg_strcasecmp".
1>libpq.lib(pgstrcasecmp.obj) : error LNK2019: Unresolved external
reference "__imp__isupper" in Funktion "_pg_strcasecmp".
1>libpq.lib(pgstrcasecmp.obj) : error LNK2019: Unresolved external
reference "__imp__toupper" in Funktion "_pg_toupper".
1>libpq.lib(pgstrcasecmp.obj) : error LNK2019: Unresolved external
reference "__imp__islower" in Funktion "_pg_toupper".
1>libpq.lib(inet_aton.obj) : error LNK2001: Unresolved external symbol
"__imp__islower".
1>libpq.lib(ip.obj) : error LNK2019: Unresolved external reference
"__imp__strtol" in Funktion "_pg_sockaddr_cidr_mask".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_FreeContextBuffer@4" in Funktion "_pg_SSPI_continue".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_InitializeSecurityContextA@48" in Funktion "_pg_SSPI_continue".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_AcquireCredentialsHandleA@36" in Funktion "_pg_SSPI_startup".
1>libpq.lib(dirmod.obj) : error LNK2019: Unresolved external reference
"__imp___stat64i32" in Funktion "_stat".
1>libpq.lib(dirmod.obj) : error LNK2019: Unresolved external reference
"__imp__unlink" in Funktion "_pgunlink".
1>libpq.lib(dirmod.obj) : error LNK2019: Unresolved external reference
"__imp__strerror" in Funktion "_pgfnames".
1>libpq.lib(thread.obj) : error LNK2001: Unresolved external symbol
"__imp__strerror".
1>libpq.lib(dirmod.obj) : error LNK2019: Unresolved external reference
"__imp__rmdir" in Funktion "_rmtree".
1>libpq.lib(inet_aton.obj) : error LNK2019: Unresolved external
reference "__imp__isxdigit" in Funktion "_inet_aton".
1>C:\Users\Julia\Documents\Visual Studio
2010\Projects\pg_con\Debug\pg_con.exe : fatal error LNK1120: 59
Unresolved external references.
I've built my libpq.lib with Visual Studio and added the include
directories and libraries of PostgreSQL to the additional dependencies
of my visual studio project, but there still seem to be missing libraries.
How can I find out which libraries I need to add?
Regards,
Julia
On Sun, Feb 27, 2011 at 15:40, Julia Jacobson <julia.jacobson@arcor.de> wrote:
Dear PostgreSQL community,
When trying to compile c++ code including libpq against the static version
libpq.lib, Visual Studio 2010 gives me the following errors:
<snip>
I've built my libpq.lib with Visual Studio and added the include directories
and libraries of PostgreSQL to the additional dependencies of my visual
studio project, but there still seem to be missing libraries.
How can I find out which libraries I need to add?
Did you build your own static version of libpq, or use the one that
comes with the installer? If the latter, then it's probably that it's
the wrong version of visual studio.
Those imports are from the Visual C runtimes, so that's what you're
missing for those - or using different versions.
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
Thanks for your answer. I was indeed using the static libpq version from
the installer.
I tried to compile my own one with Visual Studio 2010, but this caused a
lot of problems due to the fact that Visual Studio 2010 has changed the
manifest tool.
So I built a static version using Visual C++ 2008, which worked without
problems.
However, when building my application with Visual C++ 2008, the
following errors are lamented:
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__WSAIoctl@36" in Funktion "_setKeepalivesWin32".
1>libpq.lib(ip.obj) : error LNK2001: Unvresolved external symbol
"__imp__WSAIoctl@36".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__DeleteSecurityContext@4" in Funktion "_closePGconn".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external
reference "__imp__FreeCredentialsHandle@4" in Funktion "_closePGconn".
1>libpq.lib(ip.obj) : error LNK2019: Unresolved external reference
"__imp__WSASocketA@24" in Funktion "_pg_foreach_ifaddr".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_FreeContextBuffer@4" in Funktion "_pg_SSPI_continue".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_InitializeSecurityContextA@48" in Funktion "_pg_SSPI_continue".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_AcquireCredentialsHandleA@36" in Funktion "_pg_SSPI_startup".
1>C:\Users\Julia\Desktop\db_con\Debug\db_con.exe : fatal error LNK1120:
7 Unresolved external references.
Which libraries are missing now?
Am Feb 27, 2011 at 16:18, Magnus Hagander wrote:
Show quoted text
Did you build your own static version of libpq, or use the one that
comes with the installer? If the latter, then it's probably that it's
the wrong version of visual studio.Those imports are from the Visual C runtimes, so that's what you're
missing for those - or using different versions.
On Sun, Feb 27, 2011 at 18:01, Julia Jacobson <julia.jacobson@arcor.de> wrote:
Thanks for your answer. I was indeed using the static libpq version from the
installer.
I tried to compile my own one with Visual Studio 2010, but this caused a lot
of problems due to the fact that Visual Studio 2010 has changed the manifest
tool.
So I built a static version using Visual C++ 2008, which worked without
problems.
However, when building my application with Visual C++ 2008, the following
errors are lamented:1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external reference
"__imp__WSAIoctl@36" in Funktion "_setKeepalivesWin32".
1>libpq.lib(ip.obj) : error LNK2001: Unvresolved external symbol
"__imp__WSAIoctl@36".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external reference
"__imp__DeleteSecurityContext@4" in Funktion "_closePGconn".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external reference
"__imp__FreeCredentialsHandle@4" in Funktion "_closePGconn".
1>libpq.lib(ip.obj) : error LNK2019: Unresolved external reference
"__imp__WSASocketA@24" in Funktion "_pg_foreach_ifaddr".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_FreeContextBuffer@4" in Funktion "_pg_SSPI_continue".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_InitializeSecurityContextA@48" in Funktion "_pg_SSPI_continue".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_AcquireCredentialsHandleA@36" in Funktion "_pg_SSPI_startup".
1>C:\Users\Julia\Desktop\db_con\Debug\db_con.exe : fatal error LNK1120: 7
Unresolved external references.Which libraries are missing now?
At least one of those is winsock, thus probably wsock2_32 or something
like that. The SSPI stuff is from some other system library, don't
know offhand which. You can look up the missing function in the MSDN
documentation, it should list which .lib is needed to access it.
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
Thanks again for your answer.
For all those experiencing similar problems, the missing libraries were:
1) ws2_32.lib
2) secur32.lib (for the SSPI functions)
My code is compiled now without errors, but it seems to contain a buffer
overflow. So there's still some work left for me ...
Show quoted text
On Sun, Feb 27, 2011 at 19:00, Magnus Hagander wrote:
On Sun, Feb 27, 2011 at 18:01, Julia Jacobson<julia.jacobson@arcor.de> wrote:
Thanks for your answer. I was indeed using the static libpq version from the
installer.
I tried to compile my own one with Visual Studio 2010, but this caused a lot
of problems due to the fact that Visual Studio 2010 has changed the manifest
tool.
So I built a static version using Visual C++ 2008, which worked without
problems.
However, when building my application with Visual C++ 2008, the following
errors are lamented:1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external reference
"__imp__WSAIoctl@36" in Funktion "_setKeepalivesWin32".
1>libpq.lib(ip.obj) : error LNK2001: Unvresolved external symbol
"__imp__WSAIoctl@36".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external reference
"__imp__DeleteSecurityContext@4" in Funktion "_closePGconn".
1>libpq.lib(fe-connect.obj) : error LNK2019: Unresolved external reference
"__imp__FreeCredentialsHandle@4" in Funktion "_closePGconn".
1>libpq.lib(ip.obj) : error LNK2019: Unresolved external reference
"__imp__WSASocketA@24" in Funktion "_pg_foreach_ifaddr".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_FreeContextBuffer@4" in Funktion "_pg_SSPI_continue".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_InitializeSecurityContextA@48" in Funktion "_pg_SSPI_continue".
1>libpq.lib(fe-auth.obj) : error LNK2019: Unresolved external reference
"_AcquireCredentialsHandleA@36" in Funktion "_pg_SSPI_startup".
1>C:\Users\Julia\Desktop\db_con\Debug\db_con.exe : fatal error LNK1120: 7
Unresolved external references.Which libraries are missing now?
At least one of those is winsock, thus probably wsock2_32 or something
like that. The SSPI stuff is from some other system library, don't
know offhand which. You can look up the missing function in the MSDN
documentation, it should list which .lib is needed to access it.
My application looks like this:
#include <iostream>
#include "libpq-fe.h"
using namespace std;
int main(void)
{
PGconn *conn;
const char *info = "hostaddr = 'postgres.server.com' \
port = '5432' \
dbname = 'mydb' \
user = 'user' \
password = 'secret' \
connect_timeout = '3'";
conn = PQconnectdb (info);
return 0;
}
Unfortunately, I really can't figure out the problem with it.
However, the code works fine when I try to compile it using:
g++ -I"C:\Programs\PostgreSQL8.4\include" \
-L"C:\Programs\PostgreSQL\8.4\lib" \
-lpq \
main.cpp
Okay, I could fix it by myself now:
One has to tell Visual C++ to ignore msvcrt.lib.
A warning message during the compilation of my code already lamented a
conflict between msvcrt and the included libraries.
I should have taken it for serious instead of just ignoring it.
So now everything works fine and I know again why I usually prefer to
work with GNU tools and linux whenever possible.
Thanks for your help.
Show quoted text
My application looks like this:
#include <iostream>
#include "libpq-fe.h"using namespace std;
int main(void)
{
PGconn *conn;
const char *info = "hostaddr = 'postgres.server.com' \
port = '5432' \
dbname = 'mydb' \
user = 'user' \
password = 'secret' \
connect_timeout = '3'";
conn = PQconnectdb (info);
return 0;
}Unfortunately, I really can't figure out the problem with it.
However, the code works fine when I try to compile it using:
g++ -I"C:\Programs\PostgreSQL8.4\include" \
-L"C:\Programs\PostgreSQL\8.4\lib" \
-lpq \
main.cpp
Hi,
Although I finally managed to build libpq using Visual C++, I'm
continuously experiencing problems with this IDE.
Therefore I switched to MinGW and it was indeed easy to compile libpq
with it from the first time on.
However, I'm experiencing the same problem as discussed on
http://archives.postgresql.org/pgsql-hackers-win32/2004-10/msg00010.php
Although linking the static compilation product libpq.a (106 Kb in size)
to my application, the application only runs with libpq being present.
This is confirmed by running depends.exe on it, which tells me that the
application still depends on libpq.
I'm using PostgreSQL version 8.4.6 and the current version of MinGW/MSys.
How can I get a really static libpq and not one that still imports the
dynamic link libraries?
Thanks in advance,
Julia