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
  • Index
  • » Users
  • » mavis
  • » Profile

Posts

Posts

Thanks for your reply. I tried the simple example using external libraries according to openmodelica user guide and that was successful. Now i try to using modelica program call the external socket function, and there are many problem about it. i post the related file in attachment, and then i will describe my mind in detail.
1.i write a .c file which contains a simple socket function called startUP(). the .c file called my_start.c and it includes <winsock2.h> because it uses socket.
2.i write a .h file called my_start.h includs the definition of the function startUP.In this function i print a sentence to see if the modelica model calls the function.
3.generate a .o file by command : gcc -c -o my_start.o my_start.c
4.write a modelica model which calls the external function.
5.write a .mos file to run the modelica model.
But it didn't print the sentence which i write in the c function. Does it call the function? How can it work well? Thanks.
All the files are in the .zip file in attaachments below.
TEXT

Hi all,
Sorry for my poor english.
I am new to Modelica & Openmodelica. I want to use my c++ program to communicate with modelica program during simulation runtime on windows. I write a socket program which includes a .c file and a.h file and generate a .o file using gcc. Then i call the functions writen in .c file in the modelica program. But there are some errors when i do the simulation.
My problem is: how can i call socket function writen by c using external c?
Can some one help me on this problem?
Thanks & Regards

  • Index
  • » Users
  • » mavis
  • » Profile
You are here: