Skip to content

Commit

Permalink
Can now cross-compile a working omc from Linux
Browse files Browse the repository at this point in the history
Requires msys2 (installed using a pacman ported from arch Linux).
The compiled omc.exe is statically linked except for
libOpenModelicaCompiler.dll. The following configure flags were used:

'--host=i686-w64-mingw32'
'--with-omc=/usr/bin/omc'
'--without-omniORB'
'--with-lapack="-Wl,-Bstatic -lopenblas -lgfortran -lquadmath \
  -Wl,-Bdynamic -flto'
'--without-lpsolve'

CPPFLAGS:

* msys32/usr/include
* msys32/mingw32/include/tre
* msys32/mingw32/include'

LDFLAGS:
* msys32/usr/lib
* msys32/mingw32/lib
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Nov 13, 2015
1 parent f19ece7 commit be96874
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Compiler/boot/Makefile.in
Expand Up @@ -18,7 +18,7 @@ GSLIB = -L$(TOP_DIR)/3rdParty/graphstream/gs-netstream/c++/ -lnetstream
CPPFLAGS=-I"$(OMHOME)/include/omc/c" @CPPFLAGS@ -DADD_METARECORD_DEFINITIONS=
CORBALIBS=@CORBALIBS@
ULIMIT_CMD=true
SHREXT=@SHREXT@
SHREXT=@DLLEXT@
OMC=@OMC@
RPATH=@RPATH@
STATIC=@BOOTSTRAP_STATIC@
Expand Down
2 changes: 1 addition & 1 deletion Makefile.in
Expand Up @@ -45,7 +45,7 @@ LAPACK_TARGET=@LAPACK_TARGET@
OPENBLAS_EXTRA_ARGS=@OPENBLAS_EXTRA_ARGS@
IPOPT_TARGET=ipopt
UMFPACK_TARGET=@UMFPACK_TARGET@
UMFPACK_SHARED=ON
UMFPACK_SHARED=@UMFPACK_SHARED@
# We don't want the shared version, but symbols are not exported if we use the static version
# This compiles the shared and static versions, but we only copy the static version...
FMILIB_SHARED = @FMILIB_SHARED@
Expand Down
3 changes: 3 additions & 0 deletions Parser/Makefile.common
Expand Up @@ -25,10 +25,13 @@ libomantlr3.a: $(ANTLR)/src/*.c $(ANTLR)/include/*.h $(ANTLR)/antlr3config.h
ar -ru $@ antlr3*.o
ranlib $@
rm -f antlr3*.o

ifneq ($(SHREXT),.a)
libomantlr3$(SHREXT): $(ANTLR)/src/*.c $(ANTLR)/include/*.h $(ANTLR)/antlr3config.h
# build the library
$(CC) -shared -o $@ ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} -DANTLR3_NODEBUGGER $(ANTLR)/src/*.c -I$(ANTLR)/include -I$(ANTLR)
test ! `uname` = Darwin || install_name_tool -id "@rpath/$@" $@
endif

HFILES = \
ModelicaParser.h \
Expand Down
14 changes: 11 additions & 3 deletions configure.ac
Expand Up @@ -612,10 +612,13 @@ FINAL_MESSAGES="$FINAL_MESSAGES\nParModelica: $OPENCL"

AC_SUBST(CMAKE_LDFLAGS)
AC_SUBST(CMAKE_EXTRA_DEFINES)
AC_SUBST(DLLEXT)
AC_SUBST(UMFPACK_SHARED)
if test "$DARWIN" = "1"; then
APP=".app"
EXE=".app"
SHREXT=".dylib"
DLLEXT=".dylib"
LIBGC="$OMBUILDDIR/lib/$host_short/omc/libomcgc.a"
LIBSIMULATION=libSimulationRuntimeC.dylib
LIBRUNTIME=libOpenModelicaRuntimeC.dylib
Expand All @@ -642,11 +645,13 @@ if test "$DARWIN" = "1"; then
OMC_LIBS="$(OMC_LIBS) -Wl,-undefined -Wl,dynamic_lookup"
BOOTSTRAP_STATIC=""
CMAKE_LDFLAGS="-Wl,-undefined -Wl,dynamic_lookup"
UMFPACK_SHARED=ON
elif echo "$host" | grep -iq "mingw"; then
APP=".exe"
EXE=".exe"
# Yes, we build static libs on Windows, so the "shared" extension is .a
SHREXT=".dll"
SHREXT=".a"
DLLEXT=".dll"
LIBGC="$OMBUILDDIR/lib/$host_short/omc/libomcgc.a"
LIBSIMULATION=libSimulationRuntimeC.a
LIBRUNTIME=libOpenModelicaRuntimeC.a
Expand All @@ -657,7 +662,7 @@ elif echo "$host" | grep -iq "mingw"; then
CMINPACKLIB_SHARED=OFF
RT_LDFLAGS_SIM="$LDFLAGS $RT_LDFLAGS -lstdc++ -lomcgc -lexpat -lm"
RT_LDFLAGS_SIM_OPTIONAL="$SUNDIALS_LDFLAGS $IPOPT_LDFLAGS $UMFPACK_LDFLAGS -llis -lcminpack"
RT_LDFLAGS="$LDFLAGS $RT_LDFLAGS -lomcgc -lexpat -lpthread -lm"
RT_LDFLAGS="$LDFLAGS $RT_LDFLAGS -lomcgc -lexpat -Wl,-Bstatic -lpthread -Wl,-Bdynamic -static-libgcc -lm"
RT_LDFLAGS_OPTIONAL="$RT_LDFLAGS_OPTIONAL"
RT_LDFLAGS_GENERATED_CODE="$LDFLAGS -lOpenModelicaRuntimeC $RT_LDFLAGS"
RT_LDFLAGS_GENERATED_CODE_SIM="$LDFLAGS -lSimulationRuntimeC -lcdaskr $RT_LDFLAGS_SIM"
Expand All @@ -673,11 +678,13 @@ elif echo "$host" | grep -iq "mingw"; then
AC_CHECK_TOOL(WINDRES, windres, [AC_MSG_ERROR([no])])
CMAKE_EXTRA_DEFINES="-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RC_COMPILER=$WINDRES"
CPPFLAGS="$CPPFLAGS -DMSYS2_AUTOCONF=1"
OMC_LIBS="$OMC_LIBS -lstdc++ -lwsock32 -ltre -liconv -lintl -lshlwapi"
OMC_LIBS="$OMC_LIBS -lwsock32 -Wl,-Bstatic -lstdc++ -ltre -lintl -Wl,-Bdynamic -liconv -lshlwapi"
UMFPACK_SHARED=OFF
else
APP=""
EXE=""
SHREXT=".so"
DLLEXT=".so"
LIBGC="$OMBUILDDIR/lib/$host_short/omc/libomcgc.so"
LIBSIMULATION=libSimulationRuntimeC.so
LIBRUNTIME=libOpenModelicaRuntimeC.so
Expand All @@ -702,6 +709,7 @@ else
OS_TARGET="linux"
AR_SH="$AR -ru"
BOOTSTRAP_STATIC=""
UMFPACK_SHARED=ON
fi

AC_ARG_WITH(FMIL, [ --with-FMIL Link omc to FMIL (only disable when cross-compiling)],
Expand Down

0 comments on commit be96874

Please sign in to comment.