Search code examples
modelicajmodelica

Converting Modelica models from Dymola to JModelica - Addressing Errors in Log File


I am currently trying to compile the netCDF-DataReader in JModelica but it appears the package has been developed in Dymola. The process fails at the compilation stage:

netCD = compile_fmu('NcDataReader2.Examples.Simple',r'H:\Modelica\Modelica Libraries\NcDataReader2',compiler_log_level= 'w,i:log.txt')

CcodeCompilationError: Compilation of generated C code failed.

The log file created contains 326 lines. Midway it says

====== Model compiled successfully =======

But there are many errors after. Some of the errors include:

Warning: .drectve `/DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized collect2.exe: error: ld returned 1 exit status mingw32-make1: *** [ceval_] Error 1 Cannot export ??_C@_01LFCBOECM@?4?$AA@: symbol not found Cannot export ??_C@_01NOFIACDB@w?$AA@: symbol not found C:\JModelica.org-2.1\install\Makefiles\MakeFile:190: recipe for target 'fmume10' failed

I don't have much experience with compilers and debugging C-code and would prefer to spend my time focused on creating models; therefore this leads to a number of questions:

  1. Are there patterns in this errror log that could be addressed in such a way to make Dymola libraries useable in other Modelica based programs, such as JModelica?
  2. Are then any other compilers that may be more suited to cross-compatible models?
  3. Am I wasting my time trying to make Dymola models run in JModelica? Would it be more sensible to recreate the model separately in JModelica? The lack of a front-end interface makes this tricky.

Solution

  • The problem is that the external libraries available in netCDF-DataReader needs to be compiled using the GCC compiler available in the JModelica distribution. Try to recompile the libraries using GCC and put the libraries in NcDataReader2\Resources\Library\win32 (or even better put them in NcDataReader2\Resources\Library\win32\gcc472)