Jump to content

anroy

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://talesoftech.blogspot.com

Profile Information

  • Gender
    Not Telling

anroy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry it turns out this was a false alarm. Please forgive me for having wasted your time. The lesson here is to check more carefully before posting to a forum.  :-[
  2. [i]I wanted to take this to MySQL Freaks but they are down I was directed back here.  However please be warned that this problem has nothing to do with PHP, only MySQL and C.  Moderaters, please shelve it if it is too irrelevant.[/i] I set up MySQL 5.0.24 on an Ubuntu Linux machine, by downloading the source tarball. For some reason I just can't seem to get mysql_init to work, it ALWAYS returns NULL! On the MySQL site it says that this happens if there is insufficient memory.  I am sure that is not the case here. Here is my code. [code]#include </usr/local/mysql/include/mysql/mysql.h> #include <stdio.h> #include <string.h> int main() { MYSQL mysql; rc = mysql_init( &mysql ); if( rc == NULL ) { printf( "mysql_init returns NULL" ); } }[/code] I also tried the following variation, with the same NULL results. [code]#include </usr/local/mysql/include/mysql/mysql.h> #include <stdio.h> #include <string.h> int main() { MYSQL *mysql; mysql = mysql_init( NULL ); if( mysql == NULL ) { printf( "mysql_init returns NULL" ); } }[/code] Does anybody have even the slightest clue as to why I would get NULL? I compiled and linked using the following: gcc sql_prog.c -o sql_prog -lz -lmysqlclient -L /usr/local/mysql/lib/mysql/ The compile and link were successful, as the message "mysql_init returns NULL" is properly output! Also, the database server runs fine, the client programs mysqlshow, mysqladmin, etc. work fine.  They were also compiled on the same machine (I installed from source). I am thinking about copying one of the client folders (like mysqlshow) in the MySQL source, modifying the code so it does what I need, and including it in the overall MySQL build as another Client. However it is very time-consuming to configure and make the entire MySQL each time.  Maybe I can use this option? shell> ./configure --without-server Does this have any effect on the server that I am not aware of, like removing any files or settings?  I just want to rebuild the clients but want to leave the server as is. Thanks, Arka N. Roy
  3. [quote author=thorpe link=topic=103106.msg410546#msg410546 date=1154851001] There is a decent example and tutorial available on the zend site [url=http://www.zend.com/php/internals/extension-writing1.php]here[/url]. Good luck. [/quote] Thanks, that looks like a good friendly one.
  4. Earlier on I started a thread on developing PHP extensions for Windows. http://www.phpfreaks.com/forums/index.php/topic,92360.msg369800.html#msg369800 This article was an invaluable help. http://www.devnewz.com/2002/0909.html I am now creating extensions for Linux.  It is extraordinarily difficult because I barely know how to compile programs in Linux.  There are a lot of environmental issues, especially to do with paths and libraries. In the PHP source code download, there is an ext folder containing the source for the various extensions that ship with PHP.  Alas, none of them are easy to understand.  I am just looking for the "Hello World" example of extension-building.  I do not have time to learn much about gcc or Linux generally, I just need an example that works out of the box and I will just change/add the C code. The C part is a piece of cake for me, whereas the whole environment stuff is taking weeks to figure out. Does anyone know where such an example can be found? Thanks!
  5. Here is the only resource I have found that covers writing PHP extensions for Windows. http://www.devnewz.com/2002/0909.html
  6. [!--quoteo(post=381465:date=Jun 9 2006, 01:34 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 9 2006, 01:34 AM) [snapback]381465[/snapback][/div][div class=\'quotemain\'][!--quotec--] Yeah... Id'e probably agree. I would think most php developers would be working in Linux. Windows isn't exactly a great developement environment. [/quote] Actually I am going to be developing the exact same thing in Linux soon. It will be my first time developing anything in Linux (have just started using it). It looks like there will be a huge learning curve but many developers say it is more enjoyable.
  7. Haven't made much progress, this extension is pretty tough [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] I am looking for some sample code to help me to write the .dll for Windows. I have found various information on the web on writing PHP extensions but very little that is focused on Windows. Here is one, however it was written a few years ago and uses PHP 4. [a href=\"http://www.devnewz.com/2002/0909.html\" target=\"_blank\"]http://www.devnewz.com/2002/0909.html[/a] I would actually prefer if the sample code and, more importantly, [b]the Visual C++ 6 project file itself[/b] were available. Project settings are always fraught with difficulties. It is not as if I could not figure it out eventually, the problem is that right now I literally have almost no time. And I would definitely prefer something using PHP 5! Does anyone know of such a sample anywhere on the web? I realize this may be a long shot but it would help immensely if there is such a thing out there. (By the way the PHP source code has extension sources in the ext folder, but no Visual C++ project file) Thanks!
  8. [!--quoteo(post=372066:date=May 8 2006, 02:09 AM:name=neylitalo)--][div class=\'quotetop\']QUOTE(neylitalo @ May 8 2006, 02:09 AM) [snapback]372066[/snapback][/div][div class=\'quotemain\'][!--quotec--] Since you just want to do math calculations, can't you use the [a href=\"http://www.php.net/manual/en/ref.math.php\" target=\"_blank\"]PHP math library[/a]? Or am I under-estimating the complexity of your calculations? :D [/quote] It is running in PHP at the moment but it is slow. As I wrote in my original post I want to speed it up. Not rocket science in terms of complexity but just a very large number of multiplications and squaring. Looping through hundreds of thousands of these, will possibly increase to millions.
  9. [!--quoteo(post=369817:date=Apr 29 2006, 03:07 PM:name=KrisNz)--][div class=\'quotetop\']QUOTE(KrisNz @ Apr 29 2006, 03:07 PM) [snapback]369817[/snapback][/div][div class=\'quotemain\'][!--quotec--] perhaps [a href=\"http://php.net/com\" target=\"_blank\"][b]this[/b][/a] is what you're after? [/quote] Thanks for the reply, but no, I am looking for something more straightforward, like how to call a simple .dll I don't have the time to learn .NET and COM. Or is that the only option? I am also looking to do the same thing on a Linux server. So I will need the Windows and Linux solutions to be as similar as possible so I would rather stay at a fairly low level and not abstract things too far from the metal. I think the libraries on Linux are .so files? I have never programmed on Linux before. But C is common to both platform, and I just want to do math calculations, not any platform-dependent stuff, so I think I should be able to use the same source code, except perhaps for the entry point to the module.
  10. I have a feeling that Google downloads the entire WWW, at least that which it's bots can locate. For example, after a Google search if you look at the Cache links for each result, they are not just a summary of keywords of metadata, they are whole pages in their entirety. I guess if they don't do this we wouldn't get our search results so quickly, considering that billions of pages get searched. Google is simply amazing. They must have unfathomably massive amounts of storage.
  11. I need to perform some very large and processing-intensive math calculations. Speed is of the essence here, so I want to make that part run as native compiled object code, written in C/C++. PHP seems to be too slow. I want to call this C/C++ module from a PHP program running on Apache. I want to do this for both Linux and Windows. On the Windows side, I can write a DLL (Dynamically-Linked Library). Can you call a DLL from PHP? If so can you pass parameters to it, and get a return value? (The parameters and return values will, in my case, be lengthy complicated arrays. I guess this complicates things further, right? LOL ) As for the Linux side (where I am an newbie), is there anything akin to DLLs? If so what are they called? Can they be called from PHP at runtime? Any advice is appreciated, no matter how partial or indirect. Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.