I'm doing my "main" S-function based on the Matlab template with mdlStart mdlOutputs, etc, which communicates with some Ansi C files that I had, and this S-Function is used in Simulink. I compiled the files correctly with mex and in order to debug I'm using Visual Studio 2015. I can set and use breakpoints so everything is working fine.
The problem is, after finishing 'mdlOutputs' function, where all the contents are correctly printed into Matlab the debugging goes into a breakpoint and it goes into 'simulink.c'. After that, the Debug is broken saying that "libmex.pdb" cannot be found.
If I run the Simulink model without Visual Studio in the loop, Matlab just crashes and stops working.
So, any idea on how to check properly where it is giving me an error? Also, do you have any clue on why the process crashes after leaving mdlOutputs and before entering mdlTerminate? What happens in-between these two functions?
I'm using Windows 7, 64-bit and Matlab 2012b (I'm going to try and run it in the 2015b).
I think that I finally found out the solution (even though I quite don't understand it yet).
In the mdlInitializeSizes(SimStruct *S) I substituted ssSetOptions(S, 0); by ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE); like it is suggested here.
Related
I wrote a script in MATLAB and I am trying to generate C code.
I have not used C over the years so I am a little bit confused rn. I am using the MATLAB coder to generate C code automatically. This worked perfectly and now I am trying to open the C code in the Visual Studios environment and execute it. MATLAB coder did generate a C file called main.c. I guess it is an example of how to use the generated function appropriately. However, I am not able to run this program because I could not find the run button. Does anyone know, where the button is hidden?
Thank you in advance!
enter image description here
This sounds like what you need.
So this is my first post. I am preparing for some upcoming college courses on programming, one of them deals with C. I have been teaching myself for a little while and have never encountered this problem before, even though I have used the same code. I am having the issue on any ide that I use, which are MS Visual Studio 2019, and Codeblocks, both 16.01 and 17.12.
The problem is when I try to include an inline function, the compiler brings up an error: identifier "keep_window_open" is undefined, as well as the error: 'keep_window_open':identifier not found.
This never happened until I upgraded Codeblocks from 16.01 to 17.12, so that leads to believe something happened with the compiler or some settings that I don't know about, or how to change.
I have tried going back to Codeblocks 16.01, but still get the same error. All my previous programs, that use the exact same code still compile and run, so I am at a lost and completely frustrated. Enough so to think about changing my major, which I really do not want to do. I enjoy programming. But this problem is killing me.
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
inline void keep_window_open() { char ch; scanf("%s", ch); }
int main()
{
printf ("Lets see if this stupid thing works\n");
keep_Window_open();
return 0;
}
The problem is the line of code:
keep_Window_open();
If I comment it out, the program will compile and run, however I can't see it, because all it does is flash and then close the console window. And I need to use this code to see the output window. As I have said I have used this code in many other programs, most of which are much more complex than this, and they all still compile and run. It is only on new projects that I try to create.
I expect the window to stay open until the user presses and enters a key, like it always has before. I am stuck, and would appreciate some input on how to proceed, other than throw myself in front of a bus.
OK, so I was able to solve the issue in CodeBlocks, but not in Visual Studio. I changed the code to have the inline function below the main function, and now when compiled and run in CodeBlocks (17.12) it works exactly like it should, or how I thought it should.
However when I try the same solution in Visual Studio, after putting the inline function below the main function I now get a new error:
'keep_window_open' redefinition basic types
Since I usually use CodeBlocks for C, Visual Studio for C++ and intellij for java, I am not going to worry about this, as long as it works in CodeBlocks I should be OK. However I am curious as to why it work in one IDE and not the other?
I am new to this programming thing, and there is much to learn, and I know virtually nothing about compilers and linkers, as I am focusing on programming techniques and syntax in several different languages.
I have installed Linux (Ubuntu 16.04) recently, then QtCreator. Every time when I try to debug my C program in it, it falls into disassembly mode, it means when I try to step into, or even step over, it opens a file "Disassasembly(...)" and navigates in this file. It happens not only for standard functions like malloc (which source code I don't have), but also for my own functions. I thought it's because of the IDE, and installed NetBeans - and I have exactly the same problem in it.
Some example:
[it is shown after stepping over my function, and this function is just the beginning of my program, but the program ends after this screen] - edit: sorry I had to remove this file, because I can post only 2 links..
Another problem is when even for a short moment it navigates on my code (not on disassembly), it executes lines which contains documentation, and gets out to the body of another fuction, which isn't called by me at all(!) It looks like a mess...
So, I think it might be some problem with GDB, but I have no idea how to solve it. Could you help me?
GDB v. 7.11.1
gcc v. 5.4.0
NetBeans v. 8.2
EDIT: It became really weird. Today, when I tried to debug it once again, without any changes in code nor settings, the debugger started to behave almost normally, it means, that it steps through my code correctly now. The only moment, when it falls into dissasembly mode, is the end of my program, when last instruction has executed and it should end. This screens should help:
(1)
(2)
EDIT2: Ok, maybe it is quite normal now. But I still have no idea, what was wrong, and what solved the problem. I hope that it won't come back :)
I am debugging a very large c file . It is approx 70000+ lines of code. The debugger is not functioning properly, However the code is compiled correctly. Is there any flag or something which needs to be set to debug this file.
Edit:
I have changed the location of the function from bottom of file to top it is now debugging the function as expected. Don't know the reason
The easiest solution is to split the file in two, keeping each file under 65535 lines. There is rarely a good reason to have files that big. Optimizing was a weak reason in the past, but Visual Studio nowadays has /LTCG link time code generation for that.
Windows XP, Visual Studio 2005, C/C++, automation for Unigraphics NX using Open C
I'm trying to code an external program for NXOpen (i.e. a program with the NX library that runs on Windows, as opposed to an internal program that runs within NX). Right now I'm just testing to make sure the link structure is good, etc.
When I try to run the .exe that was generated, it does nothing for a few moments and then I get the following error: "The procedure entry point ?JPEG_convert_to_rgb##YAPAEHPAEPAH1#Z could not be located in the dynamic link library libimage.dll"
I have nothing to go on and Googling so far has been vastly unhelpful. The stuff on here seems to be file-specific for each case, and I'd never heard of this JPEG_convert_to_rgb before now. What can I do to fix this?
Additional info: I'm not sure if I broke something when trying to solve my last issue, or if this would have happened anyway.
It looks like you are compiling a C header file in C++ and suffering from the C++ compiler mangling your names. The DLL should export non-mangled names. Try wrapping the include of the header file in an extern "C" block.
Well, I called up GTAC. The issue turned out to be quite specific to the NX library and I'm not even fully certain what happened.
Basically, I had some environment variables that needed to be set: TC_DATA and TC_ROOT, though for some people it will be IMAN_DATA and IMAN_ROOT. These can be found if you open up NX through Teamcenter, go to Help->NX Log File, and do a ctrl-F to search for these terms. There you should find what the variables should be set to, and then set them as that. You should also make sure the UGII_BASE_DIR is set properly, and that your UGII_ROOT_DIR is at the beginning of your PATH variable. Also: call %tc_data%\tc_profilevars to set the other TC variables; call %iman_data%\iman_profilevars to set the other IMAN variables. There's also something else that I can't remember - this answer is not complete, it's just as complete as I can make it.
If this makes no sense to you, and you're using NX Open, you should probably call GTAC; if you can use an internal application instead of an external, you might be better off doing so.