|
From: Yeoh H. <ye...@ye...> - 2002-11-14 02:41:37
|
Hi Antonio, This is a response to your first question. Yes, Dev-C++ can be used to access many types of databases. Here's a general how-to approach, direct without using ODBC, that is, using the client's API. 1. Download the database and any client libraries (both source and binaries) from the database's website. For example, my latest R & D is on using SQLite, a cross-platform embeddable SQL database. http://www.sqlite.org 2. See if there are any DLLs (pre-compiled binaries), the required header file or files and any .def files. Look in the samples or test folder. Usually there are simple source that tells you which header files are required. Also, look in the folder which contains the header files to locate the required header files. 3. From the provided DLL, you need to create a library file with .a extension. Use the dlltool.exe. This program comes with Dev-C++. For example: dlltool -Dsqlite.dll -dsqlite.def -llibsqlite.a 4. Once you have this .a file, the .h file and the .dll file, you're ready to write client programs to "talk" with the database server. You then copy this .a file into your Dev-C++'s lib directory. Copy the .h file or files into the Dev-C++'s include directory. Copy the .dll into the Windows system directory. 5. Create a new Dev-C++ project. Try to find the simplest example code in the source distribution. Study the example makefile or project file. Get an idea of which defines and/or compiler switches are required. Modify/add these defines to your project file. Remove the default template code and insert the sample code. Try to compile. Notes: If the above .a file does not work or if there is no .def file, you'll need to create a .def file: This is from the MinGW FAQ: <begin extract> However, for __stdcall functions, the above method does not work. For MSVC will prefix an underscore to __stdcall functions while MinGW will not. The right way is to produce the DEF file using the pexports tool from http://www.is.lg.ua/~paul/devel/binutils.html and filter off the first underscore by sed: pexports testdll.dll | sed "s/^_//" > testdll.def Then, when using dlltool to produce the import library, add `-U' to the command line: dlltool -U -d testdll.def -l libtestdll.a <end extract> This approach I've described works for DLLs written in C, i.e. __cdecl functions. It works for MySQL's DLL and also SQLite's DLL. Instead of using the provided DLL, if you want to static link, you'll need to compile the client library source. It can be simple or complicated depending on the source. You can also try to compile a DLL using the client library source. For SQLite, the static lib is very simple to create. Use Dev-C++ to create a new project for Static Library, select C Project, then insert the SQLite C source codes. Compile and the .a file is generated. For MySQL, I've not done it. Someday I'll try to allocate some time to do it and only if I feel brave enough to try to debug compile time errors. :-) There used to be pre-compiled .a libs for MySQL from Johnny Dog website but the last time I checked the site was down. I hope this helps. Regards, Yeoh ~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~ ICT eBooks by Yeoh HS Free Downloads at http://www.yeohhs.com ~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~ |