Error

Discussion in 'Simulation' started by Gautam, May 27, 2017.

  1. Hi,
    I am trying to run the c++ file so before that I tried running makefile and I am getting the following errors

    Code:
    Gautams-MBP:sample neutrino$ ./makefile
    ./makefile: line 1: -I../include: No such file or directory
    : command not found
    : command not found all:
    ./makefile: line 4: COMMON: command not found
    basic.cpp:9:10: fatal error: 'glfw3.h' file not found
    #include "glfw3.h"
             ^
    1 error generated.
    ./makefile: line 5: COMMON: command not found
    simulate.cpp:9:10: fatal error: 'glfw3.h' file not found
    #include "glfw3.h"
             ^
    1 error generated.
    ./makefile: line 6: COMMON: command not found
    ld: library not found for -lmujoco150
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ./makefile: line 7: COMMON: command not found
    ld: library not found for -lmujoco150
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ./makefile: line 8: COMMON: command not found
    ld: library not found for -lmujoco150
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ./makefile: line 9: COMMON: command not found
    record.cpp:22:14: fatal error: 'glfw3.h' file not found
        #include "glfw3.h"
                 ^
    1 error generated.
    You had told me to run the makefile which I did and got the above errors so when I downloaded the mujoco 1.5 version by default the makefile will be in its executable format. I want to run the hello.cpp file containing hello.xml, please help me with this.
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    makefile is not an executable. it is a script for the system executable called 'make'. just type make at the command prompt in the sample directory.
     
  3. Hi yes I ran the make file. Later when I try to run this code I am getting the following errors

    Code

    Code:
    #include "mujoco.h"
    #include "stdio.h"
    
    char error[1000];
    mjModel* m;
    mjData* d;
    
    int main(void)
    {
       // activate MuJoCo Pro
    
       // load model from file and check for errors
       m = mj_loadXML("Hello.xml", NULL, error, 1000);
       if( !m )
       {
          printf("%s\n", error);
          return 1;
       }
    
       // make data corresponding to model
       d = mj_makeData(m);
    
       // run simulation for 10 seconds
       while( d->time<10 )
          mj_step(m, d);
    
       // free model and data, deactivate
       mj_deleteData(d);
       mj_deleteModel(m);
    
       return 0;
    }
    
    Error

    Code:
    Gautams-MacBook-Pro:sample neutrino$ g++ g.cpp -o g
    Undefined symbols for architecture x86_64:
      "_mj_deleteData", referenced from:
          _main in g-6f97c5.o
      "_mj_deleteModel", referenced from:
          _main in g-6f97c5.o
      "_mj_loadXML", referenced from:
          _main in g-6f97c5.o
      "_mj_makeData", referenced from:
          _main in g-6f97c5.o
      "_mj_step", referenced from:
          _main in g-6f97c5.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
     
  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    You are calling g++ without telling it to link the mujoco library, and so it is complaining that the functions are undefined.

    Look inside makefile, and you will see how g++ should be called with additional arguments specifying libraries, paths etc.