Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#3615 closed defect (fixed)

RHEL 6.7: VanDerPol FMU fails to compile: undefined reference to clock_gettime

Reported by: cxh@… Owned by: sjoelund.se
Priority: blocker Milestone: 1.9.4
Component: FMI Version:
Keywords: RHEL Cc:

Description

Under RHEL 6.7, the VanDerPol FMU fails to compile after extraction, configuration and make at link time. The error is:

include/./util/rtclock.o: In function `rt_tick':
/tmp/fmi2/tmp/sources/include/./util/rtclock.c:417: undefined reference to `clock_gettime'

The workaround is to edit Makefile and add -lrt to the LDFLAGS line.

The fix would be to modify configure to look for clock_gettime.

This error occurs when the VanDerPol.fmu file is unzipped and configure and make are run in the GitHub head version:

[cxh@terra fmi2]$ /usr/local/openmodelica/bin/omc --version
v1.9.4-dev.719+ga6c7cb2
[cxh@terra fmi2]$

To replicate:

[cxh@terra ptII]$ mkdir /tmp/fmi2
[cxh@terra ptII]$ cd /tmp/fmi2
[cxh@terra fmi2]$ cp /home/jenkins/src/OpenModelica/OMCompiler/Examples/VanDerPol.mo .
[cxh@terra fmi2]$ cp /home/cxh/src/ptII/ptolemy/actor/lib/fmi/fmus/omc/VanDerPol/VanDerPol.mos .
[cxh@terra fmi2]$ cat VanDerPol.mos
loadModel(Modelica, {"3.2.1"});
getErrorString();
loadFile("VanDerPol.mo"); getErrorString();
OpenModelica.Scripting.translateModelFMU(
        className=VanDerPol,
        version="2.0");
getErrorString();
[cxh@terra fmi2]$ env
HOSTNAME=terra.EECS.Berkeley.EDU
M2=/usr/local/apache-maven
SHELL=/bin/bash
TERM=dumb
CERTI_FED=/usr/local/certi/share/federations
HISTSIZE=1000
SSH_CLIENT=73.4.43.128 52589 22
OPENMODELICAHOME=/usr/local/openmodelica
OLDPWD=/home/cxh/src/ptII
CERTI_HOST=localhost
QTDIR=/usr/lib64/qt-3.3
QTINC=/usr/lib64/qt-3.3/include
SSH_TTY=/dev/pts/2
ANT_HOME=/usr/local/apache-ant
USER=cxh
EMACS=t
LD_LIBRARY_PATH=/usr/local/gcc-4.9.2/lib64:/usr/local/matlab/recent/sys/os/glnxa64:/home/cxh/src/ptII/lib:/usr/local/jdk/jre/lib/amd64/s\
erver:/usr/local/lib:/usr/local/matlab/recent/bin/glnxa64
LS_COLORS=
TERMCAP=
COLUMNS=137
MAIL=/var/spool/mail/cxh
PATH=/usr/local/gcc-4.9.2/bin:/usr/local/python/bin:/usr/local/gcc-4.8.2/bin:/usr/local/certi/share/scripts:/usr/local/certi/bin:/usr/lo\
cal/openmodelica/bin:/usr/java/jdk1.8.0_65/bin:/usr/local/gcc-4.9.2/bin:/usr/local/python/bin:/usr/local/gcc-4.8.2/bin:/usr/local/certi/\
share/scripts:/usr/local/certi/bin:/usr/local/openmodelica/bin:/usr/java/jdk1.8.0_65/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/\
bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hudson/src/cov-analysis-linux64-6.6.1/bin:/home/cxh/bin:/home/hudson/src/cov-analysis-linux64-\
6.6.1/bin
PWD=/tmp/fmi2
JAVA_HOME=/usr/java/jdk1.8.0_65
ANG=en_US.UTF-8
CERTI_HOME=/usr/local/certi
TOSDIR=/home/cxh/src/ptII/vendors/ptinyos/tinyos-1.x/tos
HISTCONTROL=ignoredups
PTINYOS_MOMLROOT=/home/cxh/src/ptII/vendors/ptinyos/moml
SHLVL=2
HOME=/home/cxh
LOGNAME=cxh
QTLIB=/usr/lib64/qt-3.3/lib
CVS_RSH=ssh
SSH_CONNECTION=73.4.43.128 52589 128.32.48.223 22
PTII=/home/cxh/src/ptII
LESSOPEN=||/usr/bin/lesspipe.sh %s
CCHOME=/usr/local/gcc-4.8.2
INSIDE_EMACS=23.1.1,comint
TOSROOT=/home/cxh/src/ptII/vendors/ptinyos/tinyos-1.x
G_BROKEN_FILENAMES=1
_=/bin/env
[cxh@terra fmi2]$ /usr/local/openmodelica/bin/omc --version
v1.9.4-dev.719+ga6c7cb2
[cxh@terra fmi2]$ /usr/local/openmodelica/bin/omc VanDerPol.mos
true
""
true
""
"SimCode: The model VanDerPol has been translated to FMU"
"Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
"
[cxh@terra fmi2]$ mkdir tmp
[cxh@terra fmi2]$ cd tmp
[cxh@terra tmp]$ unzip ../VanDerPol.fmu
Archive:  ../VanDerPol.fmu
   creating: binaries/
   creating: binaries/linux64/
  inflating: binaries/linux64/VanDerPol.so
 extracting: binaries/linux64/VanDerPol_FMU.libs
  inflating: binaries/linux64/config.log

...

 extracting: sources/VanDerPol_11mix.h
  inflating: sources/config.guess
[cxh@terra tmp]$ cd sources
[cxh@terra sources]$ ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: creating ./config.status
config.status: creating Makefile
[cxh@terra sources]$ make
gcc -g -O2 -fno-stack-protector -Wno-parentheses-equality -Wno-unused-variable -fPIC -DOMC_MINIMAL_RUNTIME=1 -DCMINPACK_NO_DLL=1 -Iinclu\
de/ -Iinclude/fmi2 -I.    -c -o VanDerPol_FMU.o VanDerPol_FMU.c

...


ternal_solvers/d_cnjg.o include/./external_solvers/i_len.o include/./external_solvers/i_nint.o include/./external_solvers/pow_di.o inclu\
de/./external_solvers/s_cmp.o include/./external_solvers/s_copy.o -L"/tmp/fmi2"   -Wl,--no-undefined -shared -static-libgcc -lm -lpthrea\
d
include/./util/rtclock.o: In function `rt_tick':
/tmp/fmi2/tmp/sources/include/./util/rtclock.c:417: undefined reference to `clock_gettime'
include/./util/rtclock.o: In function `rt_tock':
/tmp/fmi2/tmp/sources/include/./util/rtclock.c:429: undefined reference to `clock_gettime'
include/./util/rtclock.o: In function `rt_accumulate':
/tmp/fmi2/tmp/sources/include/./util/rtclock.c:487: undefined reference to `clock_gettime'
include/./util/rtclock.o: In function `rt_ext_tp_tock':
/tmp/fmi2/tmp/sources/include/./util/rtclock.c:534: undefined reference to `clock_gettime'
include/./util/rtclock.o: In function `rt_ext_tp_tick':
/tmp/fmi2/tmp/sources/include/./util/rtclock.c:523: undefined reference to `clock_gettime'
collect2: error: ld returned 1 exit status
make: *** [VanDerPol_FMU] Error 1
[cxh@terra sources]$ 

The fix is to edit Makefile and change:

LDFLAGS= -Wl,--no-undefined -shared -static-libgcc -lm -lpthread

to

LDFLAGS= -Wl,--no-undefined -shared -static-libgcc -lm -lpthread -lrt

The fix would be to modify configure to look for clock_gettime()

Change History (6)

comment:1 Changed 8 years ago by sjoelund.se

  • Milestone changed from Future to 1.9.4
  • Priority changed from normal to blocker

comment:2 Changed 8 years ago by sjoelund.se

Getting fixed in: https://github.com/OpenModelica/OMCompiler/pull/380 (removing use of the rtclock; should not be needed for FMUs)

Last edited 8 years ago by sjoelund.se (previous) (diff)

comment:3 Changed 8 years ago by sjoelund.se

  • Owner changed from adeas31 to sjoelund.se
  • Status changed from new to accepted

comment:4 Changed 8 years ago by sjoelund.se

  • Resolution set to fixed
  • Status changed from accepted to closed

comment:5 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4 to 1.9.4-1.9.x

Milestone renamed

comment:6 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4-1.9.x to 1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.