OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Cannot compile c++-code: undefined reference

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
hammer87
Newbie
Newbie


Joined: 11 Oct 2010
Posts: 3

PostPosted: Mon Oct 11, 2010 10:55 am    Post subject: Cannot compile c++-code: undefined reference Reply with quote

Hi,
I want to write a program, which connects to an OpenOffice, but I'm not able to compile the simplest example. I'm using g++ version 4.4.5 on Ubuntu 10.10. Here is my code:

Code:

#define UNX
#define SAL_UNX
#define CPPU_ENV gcc3

#include <stdio.h>

#include <sal/main.h>

#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>

using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::bridge;
using namespace rtl;
using namespace cppu;

int main()
{
   
   // create the initial component context
   Reference< XComponentContext > rComponentContext =
      defaultBootstrap_InitialComponentContext();

   // retrieve the servicemanager from the context
   Reference< XMultiComponentFactory > rServiceManager =
      rComponentContext->getServiceManager();

   // instantiate a sample service with the servicemanager.
   Reference< XInterface > rInstance =
      rServiceManager->createInstanceWithContext(
         OUString::createFromAscii("com.sun.star.bridge.UnoUrlResolver" ),
         rComponentContext );

   // Query for the XUnoUrlResolver interface
   Reference< XUnoUrlResolver > rResolver( rInstance, UNO_QUERY );

   if( ! rResolver.is() )
   {
      printf( "Error: Couldn't instantiate com.sun.star.bridge.UnoUrlResolver service\n" );
      return 1;
   }
   try
   {
      // resolve the uno-url
      rInstance = rResolver->resolve( OUString::createFromAscii(
         "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" ) );

      if( ! rInstance.is() )
      {
         printf( "StarOffice.ServiceManager is not exported from remote counterpart\n" );
         return 1;
      }

      // query for the simpler XMultiServiceFactory interface, sufficient for scripting
      Reference< XMultiServiceFactory > rOfficeServiceManager (rInstance, UNO_QUERY);

      if( ! rInstance.is() )
        {
            printf( "XMultiServiceFactory interface is not exported for StarOffice.ServiceManager\n" );
            return 1;
        }

        printf( "Connected sucessfully to the office\n" );
   }
   catch( Exception &e )
   {
      OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
      printf( "Error: %s\n", o.pData->buffer );
      return 1;
   }
   return 0;
}


My first question is about the defines. I've found the hint somewhere in the forum, but nowhere in the doc. Do anyone knows, which #defines I need. The defines in the code I've tried out, but don't know, if they are correct.

Second, compiling the code I get the following error:
Quote:

build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/hr87/Informatik/Qt/Oo_test/main.cpp:34: undefined reference to `cppu::defaultBootstrap_InitialComponentContext()'
build/Debug/GNU-Linux-x86/main.o: In function `OString':
/usr/include/openoffice/rtl/string.hxx:176: undefined reference to `rtl_uString2String'
build/Debug/GNU-Linux-x86/main.o: In function `~OString':
/usr/include/openoffice/rtl/string.hxx:191: undefined reference to `rtl_string_release'
build/Debug/GNU-Linux-x86/main.o: In function `~OUString':
/usr/include/openoffice/rtl/ustring.hxx:232: undefined reference to `rtl_uString_release'
build/Debug/GNU-Linux-x86/main.o: In function `rtl::OUString::createFromAscii(char const*)':
/usr/include/openoffice/rtl/ustring.hxx:1457: undefined reference to `rtl_uString_newFromAscii'
build/Debug/GNU-Linux-x86/main.o: In function `~Any':
/usr/include/openoffice/com/sun/star/uno/Any.hxx:98: undefined reference to `uno_any_destruct'
build/Debug/GNU-Linux-x86/main.o: In function `com::sun::star::bridge::cppu_detail_getUnoType(com::sun::star::bridge::XUnoUrlResolver const*)':
/usr/include/openoffice/com/sun/star/bridge/XUnoUrlResolver.hpp:25: undefined reference to `typelib_static_mi_interface_type_init'
build/Debug/GNU-Linux-x86/main.o: In function `com::sun::star::lang::cppu_detail_getUnoType(com::sun::star::lang::XMultiServiceFactory const*)':
/usr/include/openoffice/com/sun/star/lang/XMultiServiceFactory.hpp:25: undefined reference to `typelib_static_mi_interface_type_init'


Can anyone help me please.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group