Re: [Mvpmc-devel] How To build MySQL
Status: Alpha
Brought to you by:
gettler
From: Malc <ma...@po...> - 2004-10-23 12:51:01
|
MVPmc wrote: >Not sure how much this will help, but this works for me: > >The links below are for the configure file and a build script (extreamly >simple) >used to build libmysqlclient as a static library. > >ftp://www.theblains.net/build.mysql.mvpmc >ftp://www.theblains.net/configure.mysql.mvpmc > >I used mysql-4.0.21 source as the starting point. > > 1) Save the two files in the mysql-4.0.21 directory. > 2) execute build.mysql.mvpmc script. > >The very last command in the makefile will cause an error (haven't figured >out why yet), but a valid library is still created. The library is located >in the mysql-4.0.21/libmysql/.libs directory. > >I am still learning to get around in linux, so any comments would be >helpful. > >Here is a snipet of code I used to test the library (I actually placed this >in main.c of the mvpmc project to build it): > >#include "mysql.h" > >static MYSQL myDB; > >int mysql_exec_sql(MYSQL *mysql,const char *create_definition) >{ > return >mysql_real_query(mysql,create_definition,strlen(create_definition)); >} > >int main(int argc, char **argv) >{ > printf( "Starting MySQL test\n" ); > > if( mysql_init( &myDB ) == NULL) > { > fprintf( stderr, mysql_error( &myDB )); > exit(1); > } > > if( !mysql_real_connect( &myDB, "192.168.0.15", "mythtv", "mythtv", >"mythconverg", 0, NULL, 0)) > { > fprintf( stderr, mysql_error( &myDB )); > exit(1); > } > > if ( mysql_exec_sql( &myDB, "Select * from settings" ) == 0) > { > printf( "%ld Record Found\n", (long)mysql_affected_rows( >&myDB )); > > MYSQL_RES *pResults = mysql_store_result( &myDB ); > > if (pResults) > { > unsigned int nFields = mysql_num_fields( pResults ); > > MYSQL_ROW row; > > while(( row = mysql_fetch_row( pResults ))) > { > int i; > for( i=0; i < nFields; i++) > printf( "[%s] ", row[ i ] ? row[ i ] >: "NULL" ); > > printf( "\n" ); > } > } > else > printf( "pResults == NULL\n" ); > } > > printf( "MySql Test Success" ); > > mysql_close( &myDB ); > > exit( 0 ); > > } > >Hope you find this useful, > >David. > > David, sorry for the slow response... Work has kept me away from home for the last week (and thus away from the development environment), and I also discovered I lost a good chunk of the work I'd done to a disk crash. From memory and the previous version of code I had, the approach you have taken is very similar to mine.... I also built the libmysqlclient static. You also must use ulibC to ensure that you keep the executable size down I delved into the source, but couldn't fix the make problem. The mysql system doesn't really work 100% for cross complation. I found the mysql code complies itself a couple of tools. Obviously you have to complile these for your host system and not the cross compilation target! I had done a very similar trial to you for connection, which works fine. My next piece of proposed code was to try retrieving and setting bookmarks. The code in mythfrontend is already there (libmythtv ISTR). You simply need to translate from the c++ / Qt libs to raw c. We should put all of the sql code into the library as well. -malc- |