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 » U++ Library support » U++ SQL » Newbie help with PostgreSQL example
icon5.gif  Newbie help with PostgreSQL example [message #15771] Wed, 07 May 2008 16:44 Go to next message
Rottweiler is currently offline  Rottweiler
Messages: 10
Registered: May 2008
Location: Heber Springs, Arkansas, ...
Promising Member
Hi, total newbie here. I'm trying to learn how easy it is to interface to a PostgreSQL database from U++.

I've installed 2008.1Beta2. I'm trying to run the example code for accessing a PostgreSQL database as shown here:

http://www.ultimatepp.org/reference$SQL_PostgreSql.html

But I'm getting this:
----- PostgresExample ( MAIN GCC DEBUG DEBUG_FULL BLITZ WIN32 )
Postgres.cpp
In file included from C:\Projects\upp\PostgresExample\/Postgres.h:13,
                 from C:\Projects\upp\PostgresExample\Postgres.cpp:1:
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:8:22: error: libpq-fe.h: No such file or directory
In file included from C:\Projects\upp\PostgresExample\/Postgres.h:13,
                 from C:\Projects\upp\PostgresExample\Postgres.cpp:1:
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:52: error: ISO C++ forbids declaration of 'PGconn' with no type
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:52: error: expected ';' before '*' token
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:53: error: ISO C++ forbids declaration of 'PGresult' with no type
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:53: error: expected ';' before '*' token
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:66: error: expected type-specifier before 'PGconn'
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:75: error: ISO C++ forbids declaration of 'PGconn' with no type
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:75: error: expected ';' before '*' token
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:76: error: expected `;' before '}' token
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h: In member function 'virtual bool Upp::PostgreSQLSession::IsOpen() cons
	t':
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:35: error: 'conn' was not declared in this scope
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h: In member function 'Upp::String Upp::PostgreSQLSession::GetUser()':
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:65: error: 'conn' was not declared in this scope
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:65: error: 'PQuser' was not declared in this scope
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h: In constructor 'Upp::PostgreSQLSession::PostgreSQLSession()':
C:\upp\uppsrc/PostgreSQL/PostgreSQL.h:73: error: 'conn' was not declared in this scope
C:\Projects\upp\PostgresExample\Postgres.cpp: In member function 'bool PostgreSQLTest::OpenDB()':
C:\Projects\upp\PostgresExample\Postgres.cpp:64: error: 'POSTGRESS' was not declared in this scope
PostgresExample: 1 file(s) built in (0:08.18), 8188 msecs / file, duration = 8235 msecs

There were errors. (0:08.25)


I don't have a libpq-fe.h file and some of the other errors seem to be within the upp sources. Is there a more recent version of this example code or can someone get me pointed in the right direction? Thanks.
Re: Newbie help with PostgreSQL example [message #15772 is a reply to message #15771] Wed, 07 May 2008 16:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, you must actually have postgresql installed and add paths to its include and lib directories in Setup/Build methods.

Mirek
Re: Newbie help with PostgreSQL example [message #15786 is a reply to message #15771] Wed, 07 May 2008 22:36 Go to previous messageGo to next message
Rottweiler is currently offline  Rottweiler
Messages: 10
Registered: May 2008
Location: Heber Springs, Arkansas, ...
Promising Member
Thanks.

I got Postgres re-installed with headers and libs. So I'm down to this:

Postgres.cpp
C:\projects\upp\PostgresExample\Postgres.cpp: In member function 'bool PostgreSQLTest::OpenDB()':
C:\projects\upp\PostgresExample\Postgres.cpp:34: error: 'POSTGRESS' was not declared in this scope


Comes from this line:
SqlSchema sch(POSTGRESS);


I thought it might be a typo so I tried it as POSTGRES with no luck.

What is POSTGRESS and where do I find it?
Re: Newbie help with PostgreSQL example [message #15791 is a reply to message #15786] Wed, 07 May 2008 22:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I am sorry, it is a bug in example. It should be PGSQL instead of POSTGRESS.

Mirek
Re: Newbie help with PostgreSQL example [message #15795 is a reply to message #15771] Wed, 07 May 2008 23:23 Go to previous messageGo to next message
Rottweiler is currently offline  Rottweiler
Messages: 10
Registered: May 2008
Location: Heber Springs, Arkansas, ...
Promising Member
Thanks. Making progress.

Now this:
Linking...
(option '-O 2' ignored)
Target machine: I386
File 'libpq.a' not found.
Re: Newbie help with PostgreSQL example [message #15797 is a reply to message #15795] Wed, 07 May 2008 23:45 Go to previous messageGo to next message
bytefield is currently offline  bytefield
Messages: 210
Registered: December 2007
Experienced Member
Well, guess you have installed a PSQL library for MSVC compiler and trying to use it with MinGW . There is a difference between MinGW and MSVC library files, MSVC use *.lib and MinGW use *.a for extensions. Or maybe you set the wrong folders path, if lib cannot be found. For option '-O 2' it should be -O2, but it doesn't matter here, unless you want optimisation.

cdabbd745f1234c2751ee1f932d1dd75
Re: Newbie help with PostgreSQL example [message #15807 is a reply to message #15797] Thu, 08 May 2008 02:09 Go to previous messageGo to next message
Rottweiler is currently offline  Rottweiler
Messages: 10
Registered: May 2008
Location: Heber Springs, Arkansas, ...
Promising Member
bytefield wrote on Wed, 07 May 2008 16:45

Well, guess you have installed a PSQL library for MSVC compiler and trying to use it with MinGW . There is a difference between MinGW and MSVC library files, MSVC use *.lib and MinGW use *.a for extensions.

Bleah. That's a fine kettle of fish.

I used the Win32 installer from Postgresql.org and I think it's built using MSVC so I suppose that makes sense. And I seem to have no .a files anywhere on my system. Now I guess I'll have to install MSVC. Woe is me. Crying or Very Sad

bytefield wrote on Wed, 07 May 2008 16:45

For option '-O 2' it should be -O2, but it doesn't matter here, unless you want optimisation.

I didn't enter that option anywhere. And I don't see it in Setup/Build methods. I should probably enter it as a bug.
Re: Newbie help with PostgreSQL example [message #15820 is a reply to message #15771] Thu, 08 May 2008 17:02 Go to previous messageGo to next message
Rottweiler is currently offline  Rottweiler
Messages: 10
Registered: May 2008
Location: Heber Springs, Arkansas, ...
Promising Member
I've installed MSVC Express 2005. Now I'm getting this:

C:\upp\uppsrc\Core/Core.h(316) : fatal error C1083: Cannot open include file: 'windef.h': No such file or directory
MenuItem.cpp


Does this mean I need the Platform SDK or Windows SDK?

If so, does anyone know of a download link. I'm on W2k at the moment.
Re: Newbie help with PostgreSQL example [message #15821 is a reply to message #15771] Thu, 08 May 2008 17:56 Go to previous messageGo to next message
Rottweiler is currently offline  Rottweiler
Messages: 10
Registered: May 2008
Location: Heber Springs, Arkansas, ...
Promising Member
Answered my own question. Finally found a download link at MS that actually worked and got enough of it to have the windef.h file.

Now I'm getting this:

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


I have 'libpq.lib' but it's in 'C:\Program Files\PostgreSQL\8.3\lib' where the PG installer put it. There is no 'ms' to be found anywhere in that tree.

Any help?

[Updated on: Thu, 08 May 2008 18:06]

Report message to a moderator

Re: Newbie help with PostgreSQL example [message #15822 is a reply to message #15821] Thu, 08 May 2008 21:24 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 696
Registered: December 2005
Location: Budapest, Hungary
Contributor
Interesting, maybe they changed the location of that file...

In Package Organizer change PostgreSQL's library config (remove "ms\").

[Updated on: Thu, 08 May 2008 21:25]

Report message to a moderator

Re: Newbie help with PostgreSQL example [message #15824 is a reply to message #15771] Thu, 08 May 2008 23:06 Go to previous messageGo to next message
Rottweiler is currently offline  Rottweiler
Messages: 10
Registered: May 2008
Location: Heber Springs, Arkansas, ...
Promising Member
Thanks. Well, I've worked my way up to runtime errors...

SQL_PostgreSql.exe - Ordinal Not Found

The ordinal 284 could not be located in the dynamic link library SSLEAY32.dll.


Google found lots of references to this problem having something relation to SSL connection to PG. But no resolutions.

Note that I have no less than 17 copies of SSLEAY32.dll on my system with almost none of them appearing to be the same version.

Any help appreciated!
Re: Newbie help with PostgreSQL example [message #15825 is a reply to message #15824] Thu, 08 May 2008 23:41 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 696
Registered: December 2005
Location: Budapest, Hungary
Contributor
Maybe you can try PostgreSQL-8.2.
I'm using it without any problems.
Re: Newbie help with PostgreSQL example [message #15851 is a reply to message #15825] Mon, 12 May 2008 01:32 Go to previous messageGo to next message
Rottweiler is currently offline  Rottweiler
Messages: 10
Registered: May 2008
Location: Heber Springs, Arkansas, ...
Promising Member
zsolt wrote on Thu, 08 May 2008 16:41

Maybe you can try PostgreSQL-8.2.
I'm using it without any problems.

Thanks. I'm now building it against 8.2 using MSVC2005 and getting this during the link step:

Linking...
Postgres.obj : error LNK2019: unresolved external symbol "public: class Upp::ArrayCtrl::Column & __thiscall U
	pp::ArrayCtrl::AddColumn(class Upp::Id,char const *,int)" (?AddColumn@ArrayCtrl@Upp@@QAEAAVColumn@12@VId@
	2@PBDH@Z) referenced in function "public: __thiscall PostgreSQLTest::PostgreSQLTest(void)" (??0PostgreSQL
	Test@@QAE@XZ)
Postgres.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Upp::Ctrl::NcCreate
	(struct HWND__ *)" (?NcCreate@Ctrl@Upp@@UAEXPAUHWND__@@@Z)
Postgres.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Upp::Ctrl::NcDestro
	y(void)" (?NcDestroy@Ctrl@Upp@@UAEXXZ)


There's about 115 messages like that.

Any ideas.
Re: Newbie help with PostgreSQL example [message #15854 is a reply to message #15851] Mon, 12 May 2008 12:12 Go to previous message
zsolt is currently offline  zsolt
Messages: 696
Registered: December 2005
Location: Budapest, Hungary
Contributor
I think, this is a very simple problem, indicating, that you have to add CtrlLib to your main package.

[Updated on: Mon, 12 May 2008 12:12]

Report message to a moderator

Previous Topic: PostgreSQL Support Classes [Experimental]
Next Topic: sqlapp example
Goto Forum:
  


Current Time: Thu Apr 18 10:14:06 CEST 2024

Total time taken to generate the page: 0.01472 seconds