Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Issue with Arduino library

Issue with Arduino library

Hello,
For a project, I want to use an Arduino with Modelica. Then I decided to see how the library works with the examples provided, starting with the easiest one: "Blink".
But I cannot run it due to a library error:

C:/PROGRA~1/OPENMO~1.1-6/tools/msys/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lModelicaArduino
collect2.exe: error: ld returned 1 exit status
Arduino.Examples.Blink.makefile:32: recipe for target 'omc_main_target' failed
mingw32-make: *** [omc_main_target] Error 1
mingw32-make: Leaving directory 'C:/Users/NAME/AppData/Local/Temp/OPENMO~1/OMEdit/ARDUIN~1.BLI'
Compilation process failed. Exited with code 2
.



And for the warnings:

[1] 13:26:13 Ecriture Avertissement
Requested package Complex of version 3.2.3, but this package was already loaded with version 3.2.2. You might experience problems if these versions are incompatible.

[2] 13:26:13 Ecriture Avertissement
Requested package ModelicaServices of version 3.2.3, but this package was already loaded with version 3.2.2. You might experience problems if these versions are incompatible.

[3] 13:26:13 Ecriture Avertissement
Requested package Modelica of version 3.2.2, but this package was already loaded with version 3.2.3. You might experience problems if these versions are incompatible.

[4] 13:26:13 Traduction Avertissement
Assuming fixed start value for the following 40 variables:
         arduinoUno.pulseWidth[20]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.pulseWidth[19]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.pulseWidth[18]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.pulseWidth[17]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.pulseWidth[16]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.pulseWidth[15]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[20]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.portMode[19]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.portMode[18]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.portMode[17]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.portMode[16]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.portMode[15]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[14]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[14]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[13]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[13]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[4]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[4]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[6]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[6]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[7]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[7]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[1]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[1]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[2]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[2]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[9]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[9]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[8]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[8]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[5]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[5]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[3]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[3]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[12]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[12]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[11]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[11]:DISCRETE(fixed = false protected = true )  type: Integer [20]
         arduinoUno.pulseWidth[10]:DISCRETE(fixed = false protected = true )  type: Real [20]
         arduinoUno.portMode[10]:DISCRETE(fixed = false protected = true )  type: Integer [20]


[5] 13:26:13 Traduction Avertissement
[Arduino.Components.ArduinoUno: 156:4-168:16]: Could not find library ModelicaArduino in either of:
  /usr/lib//ModelicaArduino.dll
  /usr/lib//libModelicaArduino.a
  /usr/lib//libModelicaArduino.lib
  /lib//ModelicaArduino.dll
  /lib//libModelicaArduino.a
  /lib//libModelicaArduino.lib
  /usr/lib//ModelicaArduino.dll
  /usr/lib//libModelicaArduino.a
  /usr/lib//libModelicaArduino.lib
  /lib//ModelicaArduino.dll
  /lib//libModelicaArduino.a
  /lib//libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit//lib//omc/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit//lib//omc/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit//lib//omc/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit//lib//ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit//lib//libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit//lib//libModelicaArduino.lib
  %APPDATA%/.openmodelica/binaries/Arduino/ModelicaArduino.dll
  %APPDATA%/.openmodelica/binaries/Arduino/libModelicaArduino.a
  %APPDATA%/.openmodelica/binaries/Arduino/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/mingw64/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/mingw64/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/mingw64/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/win64/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/win64/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/win64/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/libModelicaArduino.lib

[6] 13:26:13 Traduction Avertissement
[Arduino.Internal.ExternalArduino: 5:3-12:18]: Could not find library ModelicaArduino in either of:
  /usr/lib//ModelicaArduino.dll
  /usr/lib//libModelicaArduino.a
  /usr/lib//libModelicaArduino.lib
  /lib//ModelicaArduino.dll
  /lib//libModelicaArduino.a
  /lib//libModelicaArduino.lib
  /usr/lib//ModelicaArduino.dll
  /usr/lib//libModelicaArduino.a
  /usr/lib//libModelicaArduino.lib
  /lib//ModelicaArduino.dll
  /lib//libModelicaArduino.a
  /lib//libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit//lib//omc/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit//lib//omc/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit//lib//omc/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit//lib//ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit//lib//libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit//lib//libModelicaArduino.lib
  %APPDATA%/.openmodelica/binaries/Arduino/ModelicaArduino.dll
  %APPDATA%/.openmodelica/binaries/Arduino/libModelicaArduino.a
  %APPDATA%/.openmodelica/binaries/Arduino/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/mingw64/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/mingw64/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/mingw64/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/win64/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/win64/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/win64/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/libModelicaArduino.lib

[7] 13:26:14 Traduction Avertissement
[Arduino.Internal.ExternalArduino: 14:3-20:17]: Could not find library ModelicaArduino in either of:
  /usr/lib//ModelicaArduino.dll
  /usr/lib//libModelicaArduino.a
  /usr/lib//libModelicaArduino.lib
  /lib//ModelicaArduino.dll
  /lib//libModelicaArduino.a
  /lib//libModelicaArduino.lib
  /usr/lib//ModelicaArduino.dll
  /usr/lib//libModelicaArduino.a
  /usr/lib//libModelicaArduino.lib
  /lib//ModelicaArduino.dll
  /lib//libModelicaArduino.a
  /lib//libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit//lib//omc/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit//lib//omc/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit//lib//omc/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit//lib//ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit//lib//libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit//lib//libModelicaArduino.lib
  %APPDATA%/.openmodelica/binaries/Arduino/ModelicaArduino.dll
  %APPDATA%/.openmodelica/binaries/Arduino/libModelicaArduino.a
  %APPDATA%/.openmodelica/binaries/Arduino/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/mingw64/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/mingw64/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/mingw64/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/win64/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/win64/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/win64/libModelicaArduino.lib
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/ModelicaArduino.dll
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/libModelicaArduino.a
  C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino/Resources/Library/libModelicaArduino.lib



I tried to uninstall, reinstall the library and Open Modelica but it did nothing.

Did someone already experience this issue? Or do you have some ideas or advice?

Thanks in advance,

LZ

Edited by: LZ - Mar-24-20 18:50:55

Re: Issue with Arduino library

You need to build the library source code into ModelicaArduino.lib using the GCC in the OpenModelica installer. To do that:

It seems the buld_mingw.bat script in directory:
%OPENMODELICAHOME%lib\omlibrary\Arduino 0.1.0\Resources\Source\Arduino
is missing some cpp files. You will need to edit it and make it look like this:

Code:


gcc -c -std=c++11 -I. -I"..\..\Include" -I"..\..\Sketches" -D"ARDUINO=100" PID_v1.cpp Servo.cpp ModelicaArduino.cpp Print.cpp Sketch.cpp SoftArduino.cpp WMath.cpp ModelicaUtilities.cpp
ar rcs ..\..\Library\win64\ModelicaArduino.lib *.o
ar rcs ..\..\Library\win64\libModelicaArduino.lib *.o

Then do Windows Start->cmd.exe and type in:

Code:


cd /D %OPENMODELICAHOME%
REM convert from long path %OPENMODELICAHOME% to short path %OM%
set OM=
for %A in ("%OPENMODELICAHOME%") do SET OM=%~sA
set PATH=%OM%\tools\msys\mingw64\bin\;%PATH%
cd "lib\omlibrary\Arduino 0.1.0\Resources\Source\Arduino"
call build_mingw.bat

This will create libModelicaArduino.lib in this directory:
%OPENMODELICAHOME%lib\omlibrary\Arduino 0.1.0\Resources\Library\win64\

Then try to build your model again.

Edited by: adrpo - Mar-23-20 16:48:38

Re: Issue with Arduino library

Thank you adrpo !
I do not have the warnings anymore but I still cannot run the example because of the error that remains the same current/hmm

Re: Issue with Arduino library

Do you have file
%OPENMODELICAHOME%lib\omlibrary\Arduino 0.1.0\Resources\Library\win64\libModelicaArduino.lib
after running the cmd commands?

Hm, after looking at your message a bit better it seems you have omlibrary\Arduino\ instead of omlibrary\Arduino 0.1.0?!
Did you downloaded the library yourself? If so, you will need to run the commands in for omlibrary\Arduino\, change:

Code:


cd "lib\omlibrary\Arduino 0.1.0\Resources\Source\Arduino"

to

Code:


cd "lib\omlibrary\Arduino\Resources\Source\Arduino"

in the script above.

Also, you need to edit lib\omlibrary\Arduino\Resources\Source\Arduino/build_mingw.bat instead of the one in lib\omlibrary\Arduino 0.1.0\Resources\Source\Arduino.

Edited by: adrpo - Mar-24-20 16:14:02

Re: Issue with Arduino library

Yes I downloaded it by myself but I finally uninstalled all and reinstall all OpenModelica before doing the manipulation from yesterday. So normally it should be good.
https://zupimages.net/up/20/13/up6d.png

I still have the error

C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino 0.1.0/Resources/Library/win64/ModelicaArduino.lib(ModelicaArduino.o):ModelicaArduino.cpp:(.text+0x24): undefined reference to `setModelicaUtilityFunctions(ModelicaUtilityFunctions_t*)'
collect2.exe: error: ld returned 1 exit status
Arduino.Examples.Blink.makefile:32: recipe for target 'omc_main_target' failed
mingw32-make: *** [omc_main_target] Error 1
mingw32-make: Leaving directory 'C:/Users/NAME/AppData/Local/Temp/OPENMO~1/OMEdit/ARDUIN~1.BLI'
Compilation process failed. Exited with code 2.

Edited by: LZ - Mar-24-20 19:09:38

Re: Issue with Arduino library

LZ wrote:

C:/Program Files/OpenModelica1.14.1-64bit/lib/omlibrary/Arduino 0.1.0/Resources/Library/win64/ModelicaArduino.lib(ModelicaArduino.o):ModelicaArduino.cpp:(.text+0x24): undefined reference to `setModelicaUtilityFunctions(ModelicaUtilityFunctions_t*)'
collect2.exe: error: ld returned 1 exit status
Arduino.Examples.Blink.makefile:32: recipe for target 'omc_main_target' failed
mingw32-make: *** [omc_main_target] Error 1
mingw32-make: Leaving directory 'C:/Users/NAME/AppData/Local/Temp/OPENMO~1/OMEdit/ARDUIN~1.BLI'
Compilation process failed. Exited with code 2.

Hello LZ,

I need to work with the Arduino in a project, too, and I got exactly the same error code like you.

The version of OpenModelica I am using is 1.14.1-64bit .

Does anyone know how to solve this error or has an idea?


Greetings,

Gela current/smile

There are 0 guests and 0 other users also viewing this topic
You are here: