Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » PostgreSQL Connection Errors
PostgreSQL Connection Errors [message #38256] Sat, 08 December 2012 05:18 Go to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Hi,


I am trying to connect to PostgreSql and it does not really work.
For now I am just trying to run the example in refernce section.

I have the DB installed and it is working I have a working schema on it.
However, when I am running the U++ example I am getting the following errors.

With the MSC10 Debug compiles perfectly but I am getting the pop up on the print-screen collage.

And with MSC10x64 I am getting the compilation errors bellow the pop on the print-screen collage.

index.php?t=getfile&id=3967&private=0


Please any suggestions and help are greatly appreciated.

Thank you.


Best,
Georgi
  • Attachment: Untitled.jpg
    (Size: 258.13KB, Downloaded 567 times)
Re: PostgreSQL Connection Errors [message #38259 is a reply to message #38256] Sat, 08 December 2012 13:54 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Unlike SqlLite, U++ support PostgreSql externally. PostgreSql's client interface source code is not included in U++. So your program compiles fine but when linking, it failed because undefined symbols.

To fix that, you should include the postgresql libary path in the link path. I remember somewhere in the manual it's taught on how to add library and library path.
Re: PostgreSQL Connection Errors [message #38260 is a reply to message #38259] Sat, 08 December 2012 14:00 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
refer to:

http://www.ultimatepp.org/app$ide$ConfiguringPackagesAssembl ies$en-us.html


Quote:


Package build settings

From TheIDE project menu, select package-organizer.


The package organizer allows the setting of a number of things affecting the package build process. The "When" column allows control of when the item in the right hand column is applied. In the above example, the -I compiler option is applied with GCC compiler and /I is applied with the Microsoft (MSC71) compiler.



Target file override. Allows specification of a name for the final executable. The default name is the package name.

Additional libraries. Allows specification of the path and name of object file libs and shared libraries that will be supplied to the linker.

Compiler options. These are text strings that will be supplied on the command line to the compiler. These will be added to the command line after (at the end of) the compiler options generated by TheIDE. These options affect all source files being compiled, not just those from the main package, however you can use build flags and the "dotted" mechanism (see Package-build-configurations above) to restrict which packages the options are applied to.

Link options. These are text strings that will be supplied on the command line to the linker. These will be added to the command line after (at the end of) the linker options generated by TheIDE.



You can also set additional compiler options for individual source files. In the "additional dependencies" list you can specify a list of files that a source file is dependent on. This means TheIDE will check these additional files to determine whether a source file should be rebuilt.


Re: PostgreSQL Connection Errors [message #38261 is a reply to message #38256] Sat, 08 December 2012 15:35 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Lance,

I am sorry I did not mention that I already linked the the Postgresql include and lib as per Mirek's post here

Best,
Georgi
Re: PostgreSQL Connection Errors [message #38266 is a reply to message #38261] Sat, 08 December 2012 17:20 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Then you probably didn't do the library and library path part right.

You need to tell the c++ linker you are using libpq.lib, and also you need to tell the linker where to find the lib file.

Can you post a screen shot of your main package package organizer?
Re: PostgreSQL Connection Errors [message #38267 is a reply to message #38256] Sat, 08 December 2012 17:58 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Lance,

I am not sure i understand what you mean with
Quote:


Can you post a screen shot of your main package package organizer?




Also I have another question.

Lets say I set it up correctly and start working locally.

When it comes time to compile the project and more specifically the server side app.
Before I compile the app do I have to again make all those references and setups with the appropriate paths to the server's database?

Thank you very much.

Best,
Georgi

[Updated on: Sat, 08 December 2012 17:58]

Report message to a moderator

Re: PostgreSQL Connection Errors [message #38270 is a reply to message #38256] Sat, 08 December 2012 18:43 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Feed:

I re-installed the postgresql db and did the whole set up again .

now the only compile error I am getting is

Quote:


LINK : fatal error LNK1104: cannot open file 'libpq.lib'





Again I am currently trying to run the reference SqlPostgres.

Thank you.

Best,
Georgi
Re: PostgreSQL Connection Errors [message #38272 is a reply to message #38267] Sat, 08 December 2012 19:29 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
On Linux, you should be fine. On windows, you can copy those *.dll to your executable folder if it's not going to be used by other programs, otherwise you can copy it to windows systems folder. It's recommended you copy the *.dll(s) that you developed and linked with. Different versions of pg client dlls might not be compatible with each other.

Re: PostgreSQL Connection Errors [message #38273 is a reply to message #38272] Sat, 08 December 2012 19:55 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Search Path Used by Windows to Locate a DLL

http://msdn.microsoft.com/en-us/library/7d83bc18%28v=vs.80%2 9.aspx

The link error could be you did not set library search path correctly in U++ Package organizer.

For extra library, you need to supply both library name and its path. I suspect you did the first part but didn't do the second part or you didn't do it correctly.
Re: PostgreSQL Connection Errors [message #38274 is a reply to message #38273] Sat, 08 December 2012 20:36 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
In Upp main menu, click Project/Package Organizer

At somewhere in the top right pane, right click, select "New Link Option..."

In the dialog, put MSC in the left, and something similar to
/LIBPATH:"C:\Program Files\PostgreSQL\9.1\lib"
in the right.

Let me know if it fixes your problem. I assume you are using MSVC tool chain.
Re: PostgreSQL Connection Errors [message #38275 is a reply to message #38256] Sat, 08 December 2012 21:04 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Here are my package organizer and build methods screens.

On the build method screen the lib and include folder paths are included under the appropriate tab the same way the bin is, I just did not want to make more screen shots.


Best,
Georgi
  • Attachment: Desktop.zip
    (Size: 104.89KB, Downloaded 185 times)
Re: PostgreSQL Connection Errors [message #38276 is a reply to message #38256] Sat, 08 December 2012 21:44 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Lance,

I connected. Very Happy

You are my PostgreSql guru Smile!!!

Whatever you see on the screenshots I posted, I just added

Quote:


In the dialog, put MSC in the left, and something similar to
/LIBPATH:"C:\Program Files\PostgreSQL\9.1\lib"
in the right.



Which is more like right click Add New Link and following your instruction above.

However, I have issues with the database I think I have to re install it again.


Also is it possible for you to post a basic example of connecting to an existing db and very simple Select/Insert qurries in U++.

Thank you a lot.

Best,
Georgi
Re: PostgreSQL Connection Errors [message #38277 is a reply to message #38256] Sat, 08 December 2012 22:19 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Lance,


It works Very Happy

I can run the example in the reference library.


How can I specify the port number to which I want it to connect?

I looked at the PostgreSql class in U++ and I did not see it there.


And this query syntax in U++ is so alien to me.

Thank you so much again and again.

Best,
Georgi
Re: PostgreSQL Connection Errors [message #38278 is a reply to message #38256] Sat, 08 December 2012 22:43 Go to previous messageGo to next message
DOTMPP is currently offline  DOTMPP
Messages: 4
Registered: December 2012
Junior Member
edit: I'll make my own thread for this question.

[Updated on: Sat, 08 December 2012 22:50]

Report message to a moderator

Re: PostgreSQL Connection Errors [message #38281 is a reply to message #38277] Sun, 09 December 2012 00:01 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Georgi

You can use most port numbers but it may be a good idea to use one that is not registered.
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_number s
Re: PostgreSQL Connection Errors [message #38283 is a reply to message #38256] Sun, 09 December 2012 01:08 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
nlneilson,

Thank you.

I know that.
My question was how can I specify that when opening the connection?



Best,
Georgi
Re: PostgreSQL Connection Errors [message #38285 is a reply to message #38283] Sun, 09 December 2012 02:08 Go to previous message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
You are welcome.

This code is from the reference example SQLPostgreSQL (or something like this)

bool PostgreSQLTest::OpenDB()
{
	if(!m_session.Open("host=localhost dbname=test user=test password=test"))
	{
		Exclamation(Format("Error in open: %s", DeQtf(m_session.GetLastError())));
		return false;
	}
	m_array.SetSession(m_session);



You should be able to supply the correct host, and one of your actual db, user and password. For the port part, you should be able to add something like port=5433 to that string.

!m_session.Open("host=localhost port=5433 dbname=mydb user=myusername password=mypassword"))
....


Let me know if it didn't work for you.
Previous Topic: SQL Syntax in PostgreSQL in U++
Next Topic: Final Compilation for Windows. How to create the .exe 101
Goto Forum:
  


Current Time: Thu Mar 28 17:31:55 CET 2024

Total time taken to generate the page: 0.01670 seconds