Opened 19 years ago

Last modified 19 years ago

#54 closed defect (fixed)

Major installation problems under Linux

Reported by: jakesson Owned by: jakesson
Priority: critical Milestone:
Component: Version:
Keywords: Cc: jakesson, haklu

Description


Change History (3)

comment:1 Changed 19 years ago by jakesson

After compiling OpenModelica under Linux, I have some experiences
that I would like to share. I had a hard time building
OpenModelica, mainly because the configure and/or makefiles did not work
properly and some tweaking was necessary in order to make it compile.
Since it is claimed that the svn distribution should compile under Linux, if
the provided pach is applied, and given the problems I encountered, I
think that these are major bugs in the installation process.

The problems may be due to that I had a different configuration than what
was expected, and in this case I would be happy to get some info on how
to set the system up in order to make it compile without doing the fixes
I had to do.

Ok, here we go.

The following configuration was used:
Linux, Fedora Core 4
antlr-2.7.2
mico-2.3.12
rml-2.3.0
OpenModelica rev 2134, downloaded using svn on 20060215

Problems and suggested solutions:

*) Contrary to what is stated on the home page, the supplied patch is needed
even if OpenModelica is obtained via svn. The patch works fine though.

*) There is an error in c_runtime/libf2c/makefile.u:

--- Line 181-185
arith.h: arithchk.c

$(CC) $(CFLAGS) -DNO_FPINIT arithchk.c -lm

$(CC) -DNO_LONG_LONG $(CFLAGS) -DNO_FPINIT arithchk.c -lm

./a.exe >arith.h
rm -f a.exe arithchk.o

---

It seems that the cygwin gcc is assumed. The problem is solved by applying
the patch

*
Index: c_runtime/libf2c/makefile.u
===================================================================
--- c_runtime/libf2c/makefile.u
+++ c_runtime/libf2c/makefile.u
@@ -181,6 +181,6 @@

arith.h: arithchk.c

$(CC) $(CFLAGS) -DNO_FPINIT arithchk.c -lm

$(CC) -DNO_LONG_LONG $(CFLAGS) -DNO_FPINIT arithchk.c -lm

  • ./a.exe >arith.h
  • rm -f a.exe arithchk.o

+ ./a.out >arith.h
+ rm -f a.out arithchk.o
*

*) There is a compile error for omc_communication.cc:

g++ -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DYYTEXT_POINTER=1
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_VPRINTF=1
-DHAVE_GETCWD=1 -DHAVE_SELECT=1 -DHAVE_STRDUP=1 -DHAVE_STRERROR=1
-DHAVE_SCANDIR=1 -DUSE_CORBA -DCYGWIN
-I/work/jakesson/software_tools/OpenModelica/RML/rml-2.3.0-src/x86-linux-gcc/include/plain
-I../../c_runtime -I../
-I/work/jakesson/software_tools/OpenModelica/MICO/mico/installation/include -c
-o omc_communication.o omc_communication.cc
omc_communication.cc:8:31: error: omc_communication.h: No such file or directory
.
.
.
more errors...
.
.
.

The error seems to appear in a file generated by the mico package and
is solve by the following patch


Index: Compiler/runtime/Makefile
===================================================================
--- Compiler/runtime/Makefile
+++ Compiler/runtime/Makefile
@@ -24,7 +24,7 @@

SHELL = /bin/sh
CC = gcc
IDL = idl

-CFLAGS += -I$(RMLINCLUDE) -I../../c_runtime -I../ $(CORBAINCL)
+CFLAGS += -I$(RMLINCLUDE) -I../../c_runtime -I../ -I. $(CORBAINCL)

CXXFLAGS = $(CFLAGS)
SRC = rtopts.c socketimpl.c printimpl.c systemimpl.c
CPPSRC = ptolemyio.cpp daeext.cpp $(CORBASRC)

*

Basically, the include statement at line 8 of omc_communication.cc reads

#include <omc_communication.h>

which implies that -I. should be given as an argument to the compiler
since omc_communication.h resides in the same directory. The other
solution would be to change the include statement to

#include "omc_communication.h"

This seems to be a bad idea since the code is automatically generated
during compilation.

*) With these changes OpenModelica compiles, and mosh can be run.
However, there is a problem when compiling a simulation model. The
makefile automatically generated by mosh looks something like

*
#Makefile generated by OpenModelica

CXX=g++
dcmotor: dcmotor.cpp

$(CXX) -o dcmotor.exe dcmotor.cpp -L$(OPENMODELICAHOME)/c_runtime/

-I$(OPENMODELICAHOME)/c_runtime/ -lsim -lg2c -lc_runtime

which does not work for a few reasons. First, there is no libg2c.a.
If, however, the makefile is changed to

*
#Makefile generated by OpenModelica

CXX=g++
dcmotor: dcmotor.cpp

$(CXX) -o dcmotor.exe dcmotor.cpp -L$(OPENMODELICAHOME)/c_runtime/

-L$(OPENMODELICAHOME)/c_runtime/libf2c -I$(OPENMODELICAHOME)/c_runtime/ -lsim
-lf2c -lc_runtime

the simulation application can be compiled. However, mosh (or rather,
the script invoked by mosh) expects the resulting file to have the
name of the Modelica model, without the .exe extension. A working
makefile is then


#Makefile generated by OpenModelica

CXX=g++
dcmotor: dcmotor.cpp

$(CXX) -o dcmotor dcmotor.cpp -L$(OPENMODELICAHOME)/c_runtime/

-L$(OPENMODELICAHOME)/c_runtime/libf2c -I$(OPENMODELICAHOME)/c_runtime/ -lsim
-lf2c -lc_runtime

To make mosh generate this makefile I applied the following patch


Index: Compiler/SimCodegen.rml
===================================================================
--- Compiler/SimCodegen.rml
+++ Compiler/SimCodegen.rml
@@ -134,5 +134,5 @@

  • "\t $(CXX) -o ",cname,".exe ", (* ".exe" is needed for a class that is in

a package. *)
+ "\t $(CXX) -o ",cname," ",

cpp_file,

  • " -L$(OPENMODELICAHOME)/c_runtime/",

+ " -L$(OPENMODELICAHOME)/c_runtime/", "
-L$(OPENMODELICAHOME)/c_runtime/libf2c",

" -I$(OPENMODELICAHOME)/c_runtime/ ",

  • " -lsim -lg2c -lc_runtime ",libs', "\n"

+ " -lsim -lf2c -lc_runtime ",libs', "\n"

which modifies the code generating the makefile.

With this change I can run the dcmotor example including instantation,
translation and simulation. However, the plotting does not work. This
is discussed in another bug report.

I realize that some of these fixes are not robust, but still, they
enabled me to build OpenModelica. I would very much appreciate
feedback on this matter and I hope that this may be useful for others
using OpenModelica under Linux.

comment:2 Changed 19 years ago by x05andre

I'm able to build OMC revision 2159 by going through this procedure:

[x05andre@pan2 ~]$ svn co
svn+ssh://remote.ida.liu.se/home/pelab/subversion/modelica/OpenModelica/trunk
OpenModelica

[x05andre@pan2 OpenModelica]$ ./configure --with-CORBA

[x05andre@pan2 OpenModelica]$ make omc

I'm using the following setup:

Fedora Core 4
antlr-2.7.4
mico-2.3.11
rml-2.3.0
omc rev 2159

There are no errors or warnings, so obviously revision 2159 works for me. Please
provide information about building rev 2159.

Either this bug is resolved or I have some settings that affect the build in
some way.

comment:3 Changed 19 years ago by adrpo

I hopefully fixed all the Linux related compilation issues
in revision 2175.
Also added updated info in a new README.Cygwin.or.Linux.txt

Note: See TracTickets for help on using tickets.