Compilation Problems for generated code for SimScape Model
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello! I basically have a similar problem as was asked before but never has been answered (although I have some extra errors): https://de.mathworks.com/matlabcentral/answers/231601-how-can-i-solve-simscape-c-code-linker-problems
I am trying to compile generated code from SimScape (Matlab2015b) and receive the following errors. Any hint on what could be the cause? Missing files maybe? I included all the .c files generated and the packages exported during code-generation. For testing I also generated a working S-Function of the SimScape Model (in 2015b still possible) and tried to recompile it and received the same errors.
Creating library Test60_sf.lib and object Test60_sf.exp
Test60_sf.obj : error LNK2019: unresolved external symbol pm_default_allocator referenced in function local_sim_data_destroy
Test60_3107f5dc_1.obj : error LNK2001: unresolved external symbol pm_default_allocator
Test60_sf.obj : error LNK2019: unresolved external symbol nesl_get_registry referenced in function nesl_lease_simulator
Test60_sf.obj : error LNK2019: unresolved external symbol neu_create_diagnostic_tree_printer referenced in function rtw_diagnostics_msg
Test60_sf.obj : error LNK2019: unresolved external symbol neu_create_diagnostic_manager referenced in function rtw_create_diagnostics
Test60_3107f5dc_1.obj : error LNK2019: unresolved external symbol ne_dae_create referenced in function Test60_3107f5dc_1_dae
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_F referenced in function ds_f
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_DF_0_1 referenced in function ds_dxf
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_DF_1_1 referenced in function ds_dxf
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_ZC_0 referenced in function ds_mode
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_ZC_1 referenced in function ds_mode
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_ZC_2 referenced in function ds_mode
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_ZC_3 referenced in function ds_mode
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_MODE_3 referenced in function ds_mode
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_MODE_2 referenced in function ds_mode
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_MODE_1 referenced in function ds_mode
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_MODE_0 referenced in function ds_mode
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_cleanup referenced in function release_reference
Test60_3107f5dc_1_ds.obj : error LNK2019: unresolved external symbol tlu2_eq_setup referenced in function Test60_3107f5dc_1_dae_ds
Test60_3107f5dc_1_gateway.obj : error LNK2019: unresolved external symbol nesl_register_simulator_group referenced in function Test60_3107f5dc_1_gateway
Test60_3107f5dc_1_gateway.obj : error LNK2019: unresolved external symbol mc_get_csparse_linear_algebra referenced in function Test60_3107f5dc_1_gateway
Test60_sf.mexw64 : fatal error LNK1120: 20 unresolved externals
Thank you!
Matlab2015b, SDK7.1
Réponses (3)
Simon Silge
le 31 Juil 2018
1 commentaire
Yougzz
le 9 Oct 2019
I have a quetsion about your example : What did you choose as Simulink solver ?
Because you can't choose discrete solver if you use PS-S converter and S-PS converter beacuse they introduce continuous states ?
I'm trying to generate code from a simscape model but I need to use a discrete solver for the global Simulink model and I can't because of these blocs.
em
le 14 Nov 2022
I had a similar experience. This is so frustrating, until you get it working, then it's super easy to do again.
What worked for me on 2018b:
- Generate simscape (or other simulink model) code. Enable the option to create a main c file that calls the function. mine was called ert_main.c. Compiling this allows you to run the generated code on your pc (without simulink), and it serves as a good template.
- go find the .mk file that was generated. This is your makefile. Inside this makefile, it specifies the include paths, object files, and libraries that you need.
- When using the s-function builder, the tricky part is the libraries list. For each of the include paths in your makefile, add it to the s-function libraries list as INC_PATH [filepath]. Next, add each of the filepaths for the object files from the makefile. Note that by default, the makefile just mentions the filename, not the full path. You need to add the full path for each object to the libraries list as [full filepath].obj. Last, you need to add the .lib files. You can find these as the libraries in the makefile. Just paste each full filepath for each library to the s-function builder.
- Note that you do not actually need to add any of the source files (.c) to the libraries list inside the s-function builder. The .obj files serve this purpose.
- You will need to remove the ert_main.obj dependancy, as your s-function builder is replacing the need for this file.
- Copy the includes from ert_main.c to the includes section in the s-function builder
- You will need to mention the global variables from your generated code in the extern function section. You do this just like any other C global definition.
- I actually had conflicts with the tmwtypes.h file which was inside programfiles/matlab. I just commented out these conflicts and it worked for me!
- from there, mapping the inputs and outputs are pretty straightforward!
0 commentaires
Voir également
Catégories
En savoir plus sur Simscape dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!