How to call C function in .m file from another function in a .mm file

I am making an interface class between a C library and an objetive C application.
I have not problem calling function the C library from .mm funstions,
but I am having problems calling .m functions from the .mm class.
here is an example of what I mean.
here in my .m vector file
*struct dVector*
* float m_x;*
* float m_y;*
* float m_z;*
* float m_w;*
*struct dVector InitVector (float x, float y, float z, float w);*
*struct dVector AddVector (struct dVector* A, struct dVector* B);*
*struct dVector SubVector (struct dVector* A, struct dVector* B);*
here is my .mm class
*#import <Foundation/Foundation.h>*
*@interface iNewton : NSObject*
* void* m_world;*
*-(id) init;*
*-(void) dealloc;*
-(void) CreateBox: (Entity*) ent: (int) shapeId;*
@end
here is the implemrntation of function funtion CreateBox in a .mm file
[code]-(void*) CreateBox: (Entity*) ent: (int) shapeId
struct dVector minBox;
struct dVector maxBox;
// this is fine
[ent GetBBox: &minBox: &maxBox];
//calculate the box size and dimensions of the physics collision shape
// this report a link errors, and I do no knwo why
struct dVector size = SubVector(&maxBox, &minBox);
struct dVector origin = AddVector (&maxBox, &minBox);
// thsi work without problemen
return NewtonCreateBox ((NewtonWorld*) world, size.m_x, size.m_y, size.m_z, shapeId, &offset.mfront.mx);
I get these compiler errors
Building target “tutorial102AddingRigidBody” of project “newton_iPhone” with configuration “Debug_Emulation” — (3 errors)
cd /Users/juliojerez/Desktop/NewtonMac/NewtonSDK/newton_iPhone
setenv MACOSXDEPLOYMENTTARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr /bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.0 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2 .1.sdk -L/Users/juliojerez/Desktop/NewtonMac/NewtonSDK/newtoniPhone/build/DebugEmulation-iphonesimulator -L/Users/juliojerez/Desktop/NewtonMac/NewtonSDK/newton_iPhone/../sdk -F/Users/juliojerez/Desktop/NewtonMac/NewtonSDK/newtoniPhone/build/DebugEmulation-iphonesimulator -filelist /Users/juliojerez/Desktop/NewtonMac/NewtonSDK/newtoniPhone/build/Debug_Emulation-iphonesimulator/tutorial_102_AddingRigidBody.build/ Objects-normal/i386/tutorial_102AddingRigidBodies.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework CoreGraphics -lnewton_iPhoneEmulation -o /Users/juliojerez/Desktop/NewtonMac/NewtonSDK/newtoniPhone/build/Debug_Emulation-iphonesimulator/tutorial_102_AddingRigidBodies.app/ tutorial_102AddingRigidBodies
Undefined symbols:
"AddVector(dVector*, dVector*)", referenced from:
-[iNewton CreateBox::] in iNewton.o
"SubVector(dVector*, dVector*)", referenced from:
-[iNewton CreateBox::] in iNewton.o
"Scale(dVector*, float)", referenced from:
-[iNewton CreateBox::] in iNewton.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
"AddVector(dVector*, dVector*)", referenced from:
-[iNewton CreateBox::] in iNewton.o
"SubVector(dVector*, dVector*)", referenced from:
-[iNewton CreateBox::] in iNewton.o
"Scale(dVector*, float)", referenced from:
-[iNewton CreateBox::] in iNewton.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Build failed (3 errors)
Basically I can call objective C class methods from .mm files,
but I can not call functions who are not members of a class from .mm funtions.
Does any one knows how I can solve this?
I have two books on objective C and neither show how to do that.
Please I will apreciate if some one can help me with this.
Julio Jerez

julio jerez wrote:
// this is fine
[ent GetBBox: &minBox: &maxBox];
why will tha be wrong?
ent is a objective C class with a method GetBBox
wich I use in hundred of places with out problem.
Beside that is not the problem that.
Well, you've got me on this one. You are correct. Apparently you don't need to specify the parameter names. Still, I strongly encourage you to use parameter names. Even though they apparently aren't required, I've never seen them not used. I would have expected to see:
[ent GetBBoxMin: & minBox max: & maxBox]
The problem is calling C function that are declared in .m files.
if you read the errors, they are linking errors not compiler errors.
this is a C function that is declared in a .m file
struct dVector size = SubVector(&maxBox, &minBox);
beside I also use those functions in many other place as well in teh project and they work.
If it helps I can post a link to the a download place to the xcode project maybe it is eassy to see what I am trying to do.
That would probably be a good idea.
Normally, all you need is
extern "C"
but there is so much missing from what you've posted that I can't tell for sure what is going on.

Similar Messages

  • How to call main method in one class from another class

    Suppose i have a code like this
    class Demo
    public static void main(String args[])
    System.out.println("We are in First class");
    class Demo1
    public static void main(String args[])
    System.out.println("We are in second class");
    In the above program how to call main method in demo calss from Demo1 class......???????

    No, i dont know how to call other than main methods from other classes
    And one more doubt i have i.e. Like in C can we see the execution of the program like how the code is being compiled step by step and how the value of the variable changes from step to step like(Add Watch).........

  • How to call a method in one JSP from another JSP?

    say that I have 2 JSPs.
    JSP one has a button.
    JSP two has some method that, say, find the square root of the number passed from JPS one.
    How to - when click - the button on page one call the method on page two?
    Please note that I can not use object binding, but I want passing the actual parameter and call the method on page two.
    Please note that this is an update of a previous post on the same topic called "Object scope".
    Thank you all very much.

    No, i dont know how to call other than main methods from other classes
    And one more doubt i have i.e. Like in C can we see the execution of the program like how the code is being compiled step by step and how the value of the variable changes from step to step like(Add Watch).........

  • How to call a sp that returns multi_columns from another sp

    Hi,
    Can anybody help me to solve this problem? I called a sp which
    returns ename, sal using a weak ref cursor from another sp. Is
    it possible to do this? or I did something wrong? The error
    messages are:
    ERROR at line 1:
    ORA-00904: invalid column name
    ORA-06512: at "SCOTT.TESTPKG", line 14
    ORA-06512: at line 1
    below is my code:
    create or replace package testpkg AS           //12/19/01
    TYPE sumCur IS REF CURSOR;
    TYPE estType IS REF CURSOR;
         function totalNo (
              dno IN NUMBER)
              RETURN estType;
         procedure test(
              sum_cv IN OUT NOCOPY sumCur);
    END;
    CREATE OR REPLACE PACKAGE BODY testpkg AS
         function totalNo (
              dno IN NUMBER)
              RETURN estType IS est_cv estType;
              BEGIN
              OPEN est_cv FOR SELECT ename, sal FROM emp
    where deptno = dno and job = 'MANAGER';
              RETURN est_cv;
         END totalno;          
         procedure test(
              sum_cv IN OUT NOCOPY sumCur) AS
              sql_statement VARCHAR2(100);
         BEGIN
              sql_statement :='SELECT dname, totalNo(deptno)
    from dept ';
              OPEN sum_cv FOR sql_statement ;
         END test;     
    END;
    Thanks

    The error that you are getting is because totalNo(deptno) needs
    to be testpkg.totalNo(deptno), but that is not the only error.
    Maybe you can use something like this:
    SQL> CREATE OR REPLACE PACKAGE testpkg
      2  AS
      3    TYPE sumcur       IS         REF CURSOR;
      4    FUNCTION totalno
      5      (dno         IN            NUMBER)
      6      RETURN                     VARCHAR2;
      7    PROCEDURE test
      8      (sum_cv      IN OUT        sumcur);
      9  END testpkg;
    10  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY testpkg
      2  AS
      3    FUNCTION totalno
      4      (dno         IN            NUMBER)
      5      RETURN                     VARCHAR2
      6    IS
      7      est_cv                     VARCHAR2 (30);
      8    BEGIN
      9      SELECT ename || ' ' || TO_CHAR (sal)
    10      INTO   est_cv
    11      FROM   emp
    12      WHERE  deptno = dno
    13      AND    job = 'MANAGER';
    14      RETURN est_cv;
    15    END totalno;
    16    PROCEDURE test
    17      (sum_cv      IN OUT        sumcur)
    18    AS
    19      sql_statement              VARCHAR2 (100);
    20    BEGIN
    21      sql_statement :=
    22         ' SELECT dname, testpkg.totalno (deptno)'
    23      || ' FROM dept';
    24      OPEN sum_cv FOR sql_statement;
    25    END test;
    26  END testpkg;
    27  /
    Package body created.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXEC testpkg.test (:g_ref)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    DNAME
    TESTPKG.TOTALNO(DEPTNO)
    ACCOUNTING
    CLARK 2450
    RESEARCH
    JONES 2975
    SALES
    BLAKE 2850
    DNAME
    TESTPKG.TOTALNO(DEPTNO)
    OPERATIONS

  • How to call the task flow  one region from another region?

    I have page with 3 regions (column wise) named as start, center, end.
    currently I having task flow for middle(i.e, center) region which have panelCollection to perform view, create, & delete functions.
    Task flow:-
    From(action)To
    View(create)Create
    Create(Done)Execute (Execute is a method call)
    Execute(*)View
    View(self)Execute
    By press create button on Center page, task flow takes to the Create page(in Centre region) but all other regions(start, end) remains same.
    I have a usecase where we have a commandLink on Start region to show the View page on Center region. but it is not able to achieve when we move to Create/Edit page.
    Plz help me out to built the same.
    Thanq
    KSB
    Edited by: user641407 on Aug 28, 2008 2:22 PM
    Edited by: user641407 on Aug 28, 2008 2:23 PM

    Hi!
    First, I'm not sure that your page layout is adequate. The regions are not intended to be navigated from outside. Yet, they can send navigation action to the container (page on which the region is placed) through Parent Action taskflow element. Also, you can investigate Contextual Events that can be raised by region, but I'm also not sure that this can be easily used for cross-region navigation.
    I would suggest you to reconsider you page layout. You can use dynamic regions (which are populated by taskflow based on menu selection or click on actionLink or s button). This way, in the Start facet you place a navigation menu (links), which are connected with dynamic region in Center. If you want to reuse a navigation links (in Start), you can put all this in page template and reuse it over and over again.
    Regards,
    PaKo

  • How to call a method of a class from another class

    Hi,
    Can some one explain me this? I want the label from the Label class to be displayed in the JFrame. I understand to do this, I have to call "label" to the ABC() and createAndShowGUI().
    I am novice. It will be really helpful if you could explain me what you did.
    class Label {
      public Label() {
      public JTextField label;
      label = new JTextField("Hi");
    public ABC() {    //Constructor
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("FrameDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JLabel emptyLabel = new JLabel("");
            emptyLabel.setPreferredSize(new Dimension(600, 400));
            frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
        }Will it be some thing like this?
    public ABC() {    //Constructor
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
                    Label label = new Label();
                    label.add
    private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("FrameDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JLabel emptyLabel = new JLabel("");
            emptyLabel.setPreferredSize(new Dimension(600, 400));
            frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
           frame.add(new Label());
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        }

    merit wrote:
    Hi,
    Can some one explain me this? I want the label from the Label class to be displayed in the JFrame. I understand to do this, I have to call "label" to the ABC() and createAndShowGUI().
    I am novice. It will be really helpful if you could explain me what you did.
    class Label {
    public Label() {
    public JTextField label;
    label = new JTextField("Hi");
    public ABC() {    //Constructor
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("FrameDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel emptyLabel = new JLabel("");
    emptyLabel.setPreferredSize(new Dimension(600, 400));
    frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }Will it be some thing like this?
    public ABC() {    //Constructor
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
    Label label = new Label();
    label.add
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("FrameDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel emptyLabel = new JLabel("");
    emptyLabel.setPreferredSize(new Dimension(600, 400));
    frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
    frame.add(new Label());
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    You know it maybe that it's just too late at night for me, but I see you complete Label class, but I don't see a class definition for ABC; you have a constructor for it, but not a class definition for it.
    In any case, when you define a class, you use it in the same way any other class is used...
    MyClass myObjectRef = new MyClass();

  • How to open Adobe Reader file from another native IOS application?

    There is an existing thread, but I want to re-open it because I think this is an important feature that we need badly.  I was wondering if there is any plan to add this feature so we can open PDFs directly into Adobe from the web / other apps.
    How to open Adobe Reader file from another native IOS application?
    Basically, we just want to use a custom URL scheme to open a specific document in the App.  Currently, this only opens the app but does not load the file.
    APB

    Not to hijack the conversation but I can explain why this would be useful for both the above case and another.
    What I believe Pavel is talking about is setting up a "URL Scheme" for the Adobe Acrobat iOS application so that you can easily open a PDF specifically in Adobe Acrobat iOS from other native applications and even from web applications opened within Safari. This is particularly useful if your application requires some of the specific features in Adobe Reader iOS to grant them the best experience possible and you want to encourage this.
    Another case: If you're using Adobe Livecycle's document security modules (that encrypts PDF files so that Adobe Acrobat must "phone home" to decrypt and view the document), these PDF's can only be viewed inside the Adobe Acrobat application and appear as blank in most other PDF readers. Having a URL scheme allows your application utilising this functionality to have a 1 click step to view the PDF rather than the current non-user friendly process:
    - Within Safari, touch the PDF link (appears as blank in the default Safari PDF reader, which in itself is confusing)
      - Touch "Open in..."
      - Touch "Adobe Acrobat"
    We have an immediate need for this functionality for the example above. I can resubmit it in a separate post if necessary.

  • How to find the existing function module is used in another function module

    Hi all,
    I created a function module and the same one is called from another function module.
    When I tried to find where the  first function module is used  using  Where-used List , I am getting the message "function module not found in selected areas" .
    Please  guide me what is other method to find whether the function module is used in another one.
    Thanks,
    Vengal Rao.

    hi,
    Go to UTILITIES-> Update Navigation index.
    or go to fucntion group and Generate the Funtion group once.
    it will detect all fucntion modules under that function group.
    regards,
    Rama

  • How to call a AM method with parameters from Managed Bean?

    Hi Everyone,
    I have a situation where I need to call AM method (setDefaultSubInv) from Managed bean, under Value change Listner method. Here is what I am doing, I have added AM method on to the page bindings, then in bean calling this
    Class[] paramTypes = { };
    Object[] params = { } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    This works and able to call this method if there are no parameters. Say I have to pass a parameter to AM method setDefaultSubInv(String a), i tried calling this from the bean but throws an error
    String aVal = "test";
    Class[] paramTypes = {String.class };
    Object[] params = {aVal } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    I am not sure this is the right way to call the method with parameters. Can anyone tell how to call a AM method with parameters from Manage bean
    Thanks,
    San.

    Simply do the following
    1- Make your Method in Client Interface.
    2- Add it to Page Def.
    3- Customize your Script Like the below one to Achieve your goal.
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("GetUserRoles");
    operationBinding.getParamsMap().put("username", "oracle");
    operationBinding.getParamsMap().put("role", "F1211");
    operationBinding.getParamsMap().put("Connection", "JDBC");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    i hope it help you
    thanks

  • I want to transfer files from a functioning hard drive in a nonfunctioning MacBook Pro to an external drive. I have an IDE/SATA drive adapter. The files won't fit on the drive for a working computer I have. Can I use it to transfer files to the external?

    I want to transfer files from a functioning hard drive in a nonfunctioning MacBook Pro to an external drive. I have an IDE/SATA drive adapter. The files won't fit on the drive for a working computer I have. Can I use it to transfer files to the external drive?

    Good luck and you are welcome.
    Like I said, I bought one of their inexpensive enclosures and now can use the hard drive just as a source for the files that are on it...my external drives are much larger and faster so I just plug that drive in when I need something from it.
    This one is on sale for $16 http://eshop.macsales.com/item/OWC/ES2.5BPU2S/

  • How to get the absolute path of a file from the local disk given the file n

    how to get the absolute path of a file from the local disk given the file name

    // will look for the file at the current working directory
    // this is wherever you start the Java application (cound be C: and your
    // application is located in C:/myapp, but the working dir is C:/
    File file = new File("README.txt"); 
    if (file != null && file.exists())
        String absolutePath = file.getAbsolutePath();

  • How to recovery the deleted files from hard disk like images,media files

    How to recovery the deleted files from hard disk like images, media files by using c#.net

    It's important to define deleted and recovery. You can recover file from the recycle bin using the Win API. Here's an
    example in C/C++. You need to
    pinvoke SHFileOperation.

  • How to embed and launch ipa file from another ipa package created using Air for iOS

    Hi Guys,
    Anybody out there knowing how to embed and launch ipa file from another ipa package created using Air for iOS ?
    I am having 1 ipa file created using Xcode, Now i need to include that file in my ipa Package which is created using Flash CS 5.5 and Air for iOS. Also i need to know how to open my 1st ipa file from AS3 ?
    Thanks,

    Hi Sir,
    Thanks for your reply.
    But in that case user need to download 2 applications right. I need user to download my parent application created using Flash and that package contain one more ipa created using Xcode, so from my parent app only user should able to open my 2nd app. Is there any way to do that?
    Ps:  I am not talking about in-app but 2 individual apps inside one package.

  • How to call Operating System commands / external programs from within APEX

    Hi,
    Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
    E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
    c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
    Any pointers will be greatly appreciated.
    Thanks & Regards,

    Hi Guys,
    I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
    However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
    sqlplusw.exe user/password@database @script1.sql
    sqlplusw.exe user/password@database @script2.sql
    sqlplusw.exe user/password@database @script3.sql
    sqlplusw.exe user/password@database @script4.sql
    What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
    Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
    Any help will be greatly appreciated.
    Thanks & Regards,

  • How to call a sql server stored procedure from oracle

    Hi all,
    Please anybody tell me how to call a sql server stored procedure from oracle.
    I've made an hsodbc connection and i can do insert, update, fetch data in sql server from oracle. But calling SP gives error. when I tried an SP at oracle that has line like
    "dbo"."CreateReceipt"@hsa
    where CreateReceipt is the SP of sql server and hsa is the DSN, it gives the error that "dbo"."CreateReceipt" should be declared.
    my database version is 10g
    Please help me how can i call it... I need to pass some parameters too to the SP
    thanking you

    hi,
    thank you for the response.
    when i call the sp using DBMS_HS_PASSTHROUGH, without parameters it works successfully, but with parameters it gives the following error
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver]Invalid parameter number[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (SQL State: S1093; SQL Code: 0)
    my code is,
    declare
    c INTEGER;
    nr INTEGER;
    begin
    c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@hsa;
    DBMS_HS_PASSTHROUGH.PARSE@hsa(c, 'Create_Receipt(?,?)');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,1,'abc');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,2,'xyz');
    nr:=DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@hsa(c);
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@hsa(c);
    end;
    Create_Receipt is the sp which requires two parameters.
    please give me a solution
    thanking you
    sreejith

Maybe you are looking for

  • 10.8: Copying wikis over from an unbootable image

    My server's hard disk became corrupt and was no longer bootable, nor repairable to the point where it's bootable.  I have a complete disk image of the unbootable volume.  I also have a bootable image of that same server but it's a few months old and

  • Error in RFC-PI-WEBSERVICE(SOAP)

    HI Expert, I am facing a problem with my scenario RFCPISOAP. It is a Asynchronous communication. Mesasge is successful in SXMB_MONI but failure in receiver side Adpter engine. Error is like Delivering the message to the application using connection S

  • Devices disappearing and taking over other device objects

    Hi everyone, I have noticed some devices in my zone suddenly start picking up bundles and polices which are not related to their device folder. I looked in the folder where the device should be and could see that the device object has disappeared. I

  • Audio and Widget Interaction

    I have audio and a widget on a slide.  When the widget appears, the audio stops.  I have searched the forums and found nothing that applies to Captivate 7 or that has a solution.  Can you please advise?

  • Session expired problem occured

    <p>i have a trouble with little red <span style=\" color:\n#ff0000;\">"<b>the session has expired</b>"</span>\nmessage<br>\non white screen . when a user from an other city try to use my\nlittle sweety brio program. at first, it works well but in his