Why i get the error "Call to undefined function node_object_prepare()" while i try to add a node programmatically in Drupal 7?
I think you will have to include node.pages.inc to be able to use this function from within your module:

module_load_include('inc', 'node', 'node.pages');


I just tried the using node_object_prepare() from a sample module without using the above code and it seems to work just fine. As @Clive mentioned is his comment you should add your code for creating a node programatically inside a module hook and not directly in your module file.

// create a node using 'hook_menu' in your module, this might not be the
// best hook for doing this but it should work
function &lt;MODULE&gt;_menu() {
  $node = new stdClass();
  $node-&gt;type = "page";
  $node-&gt;title = "Your title goes jere";
  $node-&gt;language = LANGUAGE_NONE;
  $node-&gt;path = array('alias' =&gt; 'your node path');
  node_object_prepare($node);
  // ...
}  


Reference: Module hooks