I need help on how to run/test the code examples in the sdk on Ubuntu

Hi, I'm a biogears newbie, I am using Ubuntu 14.04 and this how I tried running the example code.

g++ -o BioGearsEngineHowto ./src/BioGearsEngineHowto.cpp -std=c++11

I wanted to only test the HowTo-Asthma.cpp example so I had this class uncommented in the BioGearsEngineHowTo.cpp main function.

However I get the following error and can not figure out why:

/tmp/ccB8WE0J.o: In function `main':
BioGearsEngineHowTo.cpp:(.text+0x5): undefined reference to `HowToAsthmaAttack()'
/tmp/ccB8WE0J.o: In function `HowToTracker::HowToTracker(PhysiologyEngine&)':
BioGearsEngineHowTo.cpp:(.text+0x47): undefined reference to `TimeUnit::s'
/tmp/ccB8WE0J.o: In function `HowToTracker::AdvanceModelTime(double)':
BioGearsEngineHowTo.cpp:(.text+0x10c): undefined reference to `TimeUnit::s'
collect2: error: ld returned 1 exit status

Any response will be appreciated.


  • abrayabray Entry Level

    BioGears uses CMake to generate binaries. Unfortunately, the proper files did not get included in the Unix Zip. I apologize for the inconvenience.

    Here is a link to the CMakeLists.txt file https://drive.google.com/open?id=0B1LCQIC0vgZEaENmdFRhNkNwNXc
    Put this in the root of the SDK directory

    Create a cmake folder in the SDK directory

    Place this shell script inside the newly created cmake directory:

    Run that new shell script, it will create make files for both debug and release configurations

    Then your code (with changes) will compile and execute.

    Again, I apologize, please don't hesitate to email or keep posting if you have anymore issues.

  • Thanks for the quick response.

    I am still getting the same error as before when I try to compile the code.

    Prior to compiling I downloaded the missing files and run the new shell script successfully.
    But encountered a couple of configuration errors when I ran cmake against CMakeLists.txt like so:
    cmake ./CMakeList.txt -Denv=unixMake

    64 bits compiler detected
    CMake Error at CMakeLists.txt:79 (ADD_EXECUTABLE):
    add_executable called with incorrect number of arguments
    CMake Error at CMakeLists.txt:83 (TARGET_INCLUDE_DIRECTORIES):
    Cannot specify include directories for target "HowToDriver" which is not
    built by this project.
    CMake Error at CMakeLists.txt:84 (TARGET_INCLUDE_DIRECTORIES):
    Cannot specify include directories for target "HowToDriver" which is not
    built by this project.
    CMake Error at CMakeLists.txt:85 (TARGET_INCLUDE_DIRECTORIES):
    Cannot specify include directories for target "HowToDriver" which is not
    built by this project.
    CMake Error at CMakeLists.txt:86 (TARGET_INCLUDE_DIRECTORIES):
    Cannot specify include directories for target "HowToDriver" which is not
    built by this project.
    CMake Error at CMakeLists.txt:87 (SET_TARGET_PROPERTIES):
    set_target_properties Can not find target to add properties to: HowToDriver

    Could there be something I am doing wrong?

    Thanks again.

  • abrayabray Entry Level
    It looks like I gave you a bad CMakeLists.txt file

    Can you pull it again, I have updated it.

    It should get you farther, but we may still run into issues with it

    Keep me posted!
  • I successfully ran cmake against the new CMakeList.txt file .

    However on running the 'make' command I got a couple of errors, please check link:

  • abrayabray Entry Level
    There may be some discrepancies between your compiler version and the one we used in making the provided *.so libraries.

    Can you try downloading the source zip and building it according to our instructions here:


    I will need to investigate our linux distro next week.
    Can you give me what flavor/version of linux and compiler you are using?

  • I really appreciate the help.

    Linux distro: Ubuntu 14.04 LTS
    Compiler: gcc 4.8.4

    I'll get back to you about building the source zip.
  • Hi,
    I tried building from source.
    But I failed to get past the compilation.

    ant compile -Denv=unixMake
    **omitted all info before this point**
    [exec] [ 0%] Built target DataModelBindings
    [exec] [ 14%] Built target log4cpp
    [exec] [ 14%] Building CXX object cdm/CMakeFiles/CommonDataModel.dir/cpp/properties/SEDecimalFormat.cpp.o
    [exec] /home/cmdmaster/BioGears/src/cdm/cpp/properties/SEDecimalFormat.cpp: In member function ‘void SEDecimalFormat::SetStream(std::ofstream&)’:
    [exec] /home/cmdmaster/BioGears/src/cdm/cpp/properties/SEDecimalFormat.cpp:104:10: error: ‘defaultfloat’ is not a member of ‘std’
    [exec] s << std::defaultfloat << std::setprecision(m_Precision);
    [exec] ^
    [exec] make failed
    [exec] make[2]: *** [cdm/CMakeFiles/CommonDataModel.dir/cpp/properties/SEDecimalFormat.cpp.o] Error 1
    [exec] make[1]: *** [cdm/CMakeFiles/CommonDataModel.dir/all] Error 2
    [exec] make: *** [all] Error 2

    home/cmdmaster/BioGears/src/build.xml:301: exec returned: 1
  • abrayabray Entry Level
    I have seen this before.
    I am working on a 6.1.1 mini minor release that should get this stuff addressed, hopefully in the next week.

    We'll keep you posted.
  • abrayabray Entry Level
    It looks like you need to update the gcc compiler to the latest (gcc 6)

    Once you update it, you will need to clean out and redo the cmake and start a fresh build

  • Hi mousalgf,

    The Linux SDK includes a build-linux.sh script which can be used to build the HowTo files. The SDK contains precompiled binaries that the HowTo files link to, you shouldn't have to compile the source yourself or mess with CMake. Running that script in the library/src directory will result in an executable being placed in the library/bin directory.

    The only potential problem as Aaron pointed out is that you may run into a mismatch when linking to libstdc++.so.6. We dynamically link to this library so it looks for your particular version which may be out of date (or more up to date). If you end up running into this problem, it might be possible for me to send you my libstdc++.so.6 to get things working correctly until we resolve this issue.

    For reference, we built the Linux SDK on Ubuntu 16.04 using gcc 5.4.
  • Hi dbyrd,

    Thanks for your response.

    On executing the build-linux.sh, I got a batch errors.

    I noticed that the compiler couldn't find the engine creation class plus a few others in all the scenarios.
    Does this have something to do with the linking step you mentioned?

    Since I happen to have libstdc++.so.6 file in /usr/lib/x86_64-linux-gnu, I attempted to get the compile to search this path using "-Wl,-rpath=path" option, However I got the following error.

    /usr/bin/ld: cannot find /usr/lib/x86_64-linux-gnu: File format not recognized
    collect2: error: ld returned 1 exit status

    Another desperate move was adding it to LD_LIBRARY_PATH but that didn't help either.

    *Currently using gcc 6.2.0 on Ubuntu 14.04

    I tried building from source too, like you'd suggested but could get passed this step
    ant compile -Denv=unixMake

    Find output here.

  • abrayabray Entry Level
    All those link errors are in reference to classes found in the DataModelBindings library.
    Did you run cmake via the shell script or the ant script? I am going to assume the shell script.

    Can you run cmake via ant with : ant cmake

    This is going to run a xsd to cpp library (Code Synthesis) to generate all of those missing classes.
    You should get a ton of hxx and cxx class in your src/schema/cpp/bind directory

    There is also an ant touch file you may need to delete : src/schema/cpp_schema_built

    Give this a shot, and see if that doesn't solve your linking problems, if not, I will keep trying to help you out.
  • Hi abray,
    I appreciate your help.

    I did run cmake like so:
    ant cmake -Denv=unixMake, <-- this run without any issues
    ant compile -Denv=unixMake

    Note: src/schema/cpp_schema_built doesn't exist

    This was the output I got.

    **some info omitted

    [exec] [ 89%] Building CXX object cdm/CMakeFiles/CommonDataModelTest.dir/test/cpp/Substances/ReadSubstanceDirectory.cpp.o
    [exec] Linking CXX shared library CommonDataModelTest.so
    [exec] [ 89%] Built target CommonDataModelTest
    [exec] Scanning dependencies of target CommonDataModelJNI
    [exec] [ 89%] Building CXX object cdm/CMakeFiles/CommonDataModelJNI.dir/cpp/CommonDataModelJNI.cpp.o
    [exec] make failed
    [exec] /home/cmdmaster/BioGears/src/cdm/cpp/CommonDataModelJNI.cpp:13:17: fatal error: jni.h: No such file or directory
    [exec] #include <jni.h>
    [exec] ^
    [exec] compilation terminated.
    [exec] make[2]: *** [cdm/CMakeFiles/CommonDataModelJNI.dir/cpp/CommonDataModelJNI.cpp.o] Error 1
    [exec] make[1]: *** [cdm/CMakeFiles/CommonDataModelJNI.dir/all] Error 2
    [exec] make: *** [all] Error 2

    /home/cmdmaster/BioGears/src/build.xml:301: exec returned: 1
  • abrayabray Entry Level
    Ahhhhhh, you need to install the JDK (java development kit)
    It looks like everything is building though.
    The unit test suite for BioGears is driven through Java.
    So we gave some JNI interfaces. Those are failing to build as they are dependent on the JDK.

    You could also comment out the JNI projects from the cmake files.

    But you also should have good .so objects now too, you could try copying those to the SDK folder and rebuilding the SDK at this point

    You should only need the log4cpp, DataModelBindings, CommonDataModel, and BioGearsEngine so files (and the code synthesis so, that should be easy to build too from their site instructions)

  • edited June 2017
    Upgrading to ubuntu 16.04 solved my issue, I am now able to use the SDK without any problems at all. I guess there were some incompatibility issues with ubuntu 14.04.
    Thank you all for your help.
Sign In or Register to comment.