- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using linux and wander whether it's possible to link to MySQL in f90. Any suggestion is appreciated!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You probably noticed there is a prior thread about this
http://software.intel.com/en-us/forums/topic/344492
but you aren't at all specific about what problem you are facing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, that other thread is for Windows. Doing a Google search on "mysql fortran linux" shows several promising links. http://asthomas.com/mysql_dist/MySQL_AST.htm looks especially interesting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for the reply!
I have google a lot, and found some solution, but I'm new in both linux and mysql, it's very hard to follow those step. Here is what I did:
I have downloaded mysql.f90by Daniel Kraft. Then I compiled it with ifort -c mysql.f90 to got the myfortran_binding.mod and mysql.o . Then I wrote a main program test.f90 with only one sentenct USE myfortran_binding and compiled it. Then I linked the two together with ifort test.o mysql.o and got the following errors
mysql.o: In function `myfortran_binding_mp_myfortran_connect_':
mysql.f90:(.text+0x61): undefined reference to `mysql_init'
mysql.f90:(.text+0x261): undefined reference to `mysql_connect'
mysql.f90:(.text+0x2b6): undefined reference to `c_error'
mysql.o: In function `myfortran_binding_mp_myfortran_disconnect_':
mysql.f90:(.text+0x344): undefined reference to `mysql_close'
and so on. I'm sure I have missed something important but I don't know what is it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you have a mysql library to link against?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have mysql in the linux server and I can access it without any problem. But I don't know where the library is and how to link it? So I should link my program something like this ?
ifort test.o mysql.o mysql_library.o
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The library would be more likely to appear as a libmysql.a or .so file; you could link either by appending the library name, as you suggested, or by adding -L/sql_library_directory/ -lmysql
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried
find / -name libmysql
but got nothing. And I tried go to /usr/lib but still find nothing. I tried search on the Internet but still don't know how to install this library (I download mysql-connector-c-6.0.2-linux-glibc2.3-ia64-64bit from http://dev.mysql.com/downloads/ but don't work). I use
apt-cache search libmysql
there is only c++ edition. Please give me some tip how I can install the library?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hang S.
as TimP mentioned, the thread http://software.intel.com/en-us/forums/topic/344492 contains a lot of information on MySQL and Fortran bindings. In my posts in this thread you will find a slightly modified version of Daniel Kraft's mysql-fortran-bindings. For me this works very nice on Windows x64 with ifort (12.1.x.x) and Linux x64 with GCC 4.6.x as well as ifort. Be shure to use x64. At 32 bit you will get problems with STDCALL and ifort (for Windows, Linux 32 bit no idea whether it works without problems).
As Linux distro we use ScientificLinux 6.3 and SuseEnterprize 11.1 and the most current version of mysql-client for these platforms. Recently I tested Mint 13 LTS also successfully. On all systems we use Eclipse Indigo SR2 for Parallel Applications as IDE. There we set the linker to link against /usr/lib/64/mysql/libmysqlclient_r.so on SELinux. The location of this lib varies on the Linux distributions. I don't know whether the C++ connectors work too. We just installed mysql-client via the package manager.
Hope that helped.
Kind regards,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may use "locate libmysqlclient.so" or "locate libmysqlclient_r.so" to find the location of the necessary lib (/usr/lib/x86_64-linux-gnu/libmysqlclient.so at Mint 13 LTS). No results means that mysqlclient is not installed. Just as an info, the _r version is the thread-save version we use for our parallel application. You don't need to install the connectors if you already have mysql-client.
Regards,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi TimP, Johannes :
Thank you so much! I finally succeed, using mod-mysqlfortran-binding.f90. And find the libmysqlclient.so under/usr/lib/x86_64-linux-gnu/ .Now I can link my program successfully and do query to mysql. It was wonderful !
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page