Page 1 of 1

Get Database Layer to Work

Posted: Mon Mar 16, 2009 8:15 pm
by wagb278
I'm new to wxWidgets and Database Layer. As a hobby program I want to write a program that allows the end-user to choose either SQLite3 or MySQL as the database engine. It looks like "Database Layer" is just the ticket - but I seem to be missing something (knowledge).

I tried the make -f GNUmakefile sqlite (and mysql) and the response was "nothing to be done for 'sqlite' (and 'mysql'). I edited GNUmakefile to add paths for Sqlite and mysql (/usr/include and /usr/lib). I verified that the mysql.h and sqlite.h files exist.

I assume I need to Make Database Layer to get the header and library files "databaselayer_mysql.a" and "databaselayer_sqlite.a". I have mysql and sqlite libraries in /usr/lib; but no "databaselayer" library files - so why does the Make say there is "nothing to do"?

I am using Ubuntu 8.04 Linux. I installed Code::Blocks SVN 5456 which comes with wxWidgets wx2.8.8 (Linux, unicode). MySQL and SQLite3 are working.

I have built a test program using mysql in code::blocks using the mysql++ wrapper, so I know the mysql header and library are good - not played with Sqlite other than the command line.

Any ideas?

Posted: Tue Mar 17, 2009 5:22 pm
by jb_coder
The issue may be that your copy of the DatabaseLayer GNUmakefile was only written for static builds of wxWidgets. The version of GNUmakefile at ... vision=784

may fix the problem.

Making headway

Posted: Wed Mar 18, 2009 2:00 am
by wagb278
That GNUmakefile was an improvement. I ran it (unmodified) for mysql and it did a bunch of compiles, etc. but I don't think it completed satisfactorily. I ran it as because the first time I tried it gave a fatal error due to permission denied:

Code: Select all

sudo make GNUmakefile mysql
But it did not write any "databaselayer - " lib file(s) to /usr/lib. I noticed a number of WARNINGS related to type-punned pointer is that significant?

The end of the terminal session is:

Code: Select all

/usr/include/wx-2.8/wx/gdicmn.h: In member function ‘wxStringToColourHashMap_wxImplementation_HashTable::Node** wxStringToColourHashMap_wxImplementation_HashTable::GetNodePtr(const wxString&) const’:
/usr/include/wx-2.8/wx/gdicmn.h:544: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from /usr/include/wx-2.8/wx/wx.h:45,
                 from ../src/../include/MysqlResultSetMetaData.h:12,
                 from ../src/MysqlResultSetMetaData.cpp:1:
/usr/include/wx-2.8/wx/image.h: In member function ‘wxImageHistogramBase_wxImplementation_HashTable::Node** wxImageHistogramBase_wxImplementation_HashTable::GetNodePtr(const long unsigned int&) const’:
/usr/include/wx-2.8/wx/image.h:136: warning: dereferencing type-punned pointer will break strict-aliasing rules
g++ -shared -fPIC -o ../lib/gcc_dll/ gccgtk2_dll/databaselayer_mysql_dll_DatabaseLayer.o gccgtk2_dll/databaselayer_mysql_dll_DatabaseResultSet.o gccgtk2_dll/databaselayer_mysql_dll_PreparedStatement.o gccgtk2_dll/databaselayer_mysql_dll_DatabaseErrorReporter.o gccgtk2_dll/databaselayer_mysql_dll_DatabaseStringConverter.o gccgtk2_dll/databaselayer_mysql_dll_DatabaseQueryParser.o gccgtk2_dll/databaselayer_mysql_dll_MysqlDatabaseLayer.o gccgtk2_dll/databaselayer_mysql_dll_MysqlParameter.o gccgtk2_dll/databaselayer_mysql_dll_MysqlPreparedStatement.o gccgtk2_dll/databaselayer_mysql_dll_MysqlPreparedStatementParameter.o gccgtk2_dll/databaselayer_mysql_dll_MysqlPreparedStatementParameterCollection.o gccgtk2_dll/databaselayer_mysql_dll_MysqlPreparedStatementResultSet.o gccgtk2_dll/databaselayer_mysql_dll_MysqlPreparedStatementWrapper.o gccgtk2_dll/databaselayer_mysql_dll_MysqlResultSetMetaData.o   -L../lib -L./lib `mysql_config --libs`  -lmysqld `wx-config --debug=no --unicode=yes --static=no --toolkit=gtk2 --version=2.8 --libs base`
Can you tell me what I need to do? Should I have made configuration changes to GNUmakefile?

I am surprised that it is accessing DLL files - I thought that was a Microsoft thing, not a Linux file format.

I ran the make for sqlite which resulted in the following, this time I remembered to redirect the log to a file:

Code: Select all

g++ -shared -fPIC -o ../lib/gcc_dll/ gccgtk2_dll/databaselayer_sqlite_dll_SqliteDatabaseLayer.o gccgtk2_dll/databaselayer_sqlite_dll_SqlitePreparedStatement.o gccgtk2_dll/databaselayer_sqlite_dll_SqliteResultSet.o gccgtk2_dll/databaselayer_sqlite_dll_SqliteResultSetMetaData.o gccgtk2_dll/databaselayer_sqlite_dll_DatabaseLayer.o gccgtk2_dll/databaselayer_sqlite_dll_DatabaseResultSet.o gccgtk2_dll/databaselayer_sqlite_dll_PreparedStatement.o gccgtk2_dll/databaselayer_sqlite_dll_DatabaseErrorReporter.o gccgtk2_dll/databaselayer_sqlite_dll_DatabaseStringConverter.o gccgtk2_dll/databaselayer_sqlite_dll_DatabaseQueryParser.o  -L./lib  -L../lib  -lsqlite3 `wx-config --debug=no --unicode=yes --static=no --toolkit=gtk2 --version=2.8 --libs base`

Posted: Wed Mar 18, 2009 4:58 pm
by jb_coder
The build should create the intermediate files in databaselayer/build/gccgtk2_dll and the output files in databaselayer/lib/gcc_dll (or something similar under the databaselayer/lib directory). Was a file ending in ".so" or ".a" created anywhere under the databaselayer/lib directory?

I think the "_dll_" naming convention is part of the wxCode Bakefile defaults. It uses "_lib_" when creating a static library and "_dll_" when creating a shared library. On Linux, the shared output file will still have ".so" extension rather than ".dll" (as far as I know).

From the output you provided, it looks like the shared library was successfully created in the "databaselayer/lib/gcc_dll" directory. You should be able to link your application code to that library file.


Posted: Thu Mar 19, 2009 12:57 am
by wagb278
You are correct - I was expecting the files to appear in /usr/lib; but they are where you said they would be.

The files are:

Code: Select all
Am I correct assuming the "2.8" refers to the version of wxWidgets and not mysql or sqlite?

I probably wont get a chance to try linking to them until the weekend. I will report then if I have further problems.


Re: Fixed

Posted: Thu Mar 19, 2009 5:15 am
by mc2r
wagb278 wrote:You are correct - I was expecting the files to appear in /usr/lib; but they are where you said they would be.
Generally you need to do a make install or sudo make install to get the files to appear in /usr/lib, the other targets like GNUmakefile and mysql will only build those components not install them.

Just a general Make rule. I've never built this component so I might be wrong in regards to it.


Posted: Thu Mar 19, 2009 8:26 am
by jb_coder
Yes, the 2.8 refers to the wxWidgets version. That's another one of the wxCode naming conventions.

Lib and Header File Locations

Posted: Sun Mar 22, 2009 4:33 pm
by wagb278
This might be a little bit off topic, and dumb.

Where on Linux (Ubuntu) should I place the databaselayer library files and header files? What is the norm?

I downloaded and built the databaselayer in:
/usr/share/doc/databaselayer - Maybe that was a mistake.

Can I safely copy (or should I create a symbolic link) the databaselayer include files to:
- and a similar location for the library files under /usr/lib?

Inspecting /usr/lib/wx, I see only "config" and "include" subdirectories with lib files for "base" and "gtk2". Do those libs include all the wxWidgets basic (non-third-party) functionality needed for the link operation?

I tried the make install, but that did not move/copy my databaselayer library files for mysql and sqlite.

Any suggestions - recommendations?


Posted: Tue Mar 24, 2009 11:30 am
by jb_coder
I don't know if there is a wxCode standard that DatabaseLayer should be following, but I'll refer to the Readme.txt file of wxSQLite3 ( ... Readme.txt) which says:

Code: Select all

The autoconf-based systems also support a "make install" target which
builds the library and then copies the headers of the component to
/usr/local/include and the lib to /usr/local/lib.
So I guess "/usr/local/" might be an acceptable choice of where to put these files.