Using Visual Studio 2008 with Code Warrior compiler - c

New to the site. I am hoping you can help me as I've been beating my head against the wall on this one for a month now.
This is for work, and we are kind of proprietary but I will try to share as much information as possible. We have MPC5674F microcontroller on our main development board. To write code before, we used Microsoft Visual Studio 2008 along with a makefile and gcc compiler to create a .s19 file that is then flashed onto the board. Before, Visual Studio would not recognize make command. I went into C:\MinGW folder and found 3 different make.exe type files. There is gnatmake.exe, mingw32-make.exe and regular make.exe in C:\MinGW\msys\1.0\bin. I also found a regular make.exe in an NXP folder from the S32Design Studio. All of those make commands give me different result. If I change one that is by MinGW, then it gets stuck in the makefile saying The system cannot find the path specified to an echo.exe command, even though I can once again go into command window and type echo and it outputs ECHO is on. If I use just make.exe from either NXP of the other folder from MinGW, it compiles without errors but there is no file output, or even the process of how it compiled. In our makefile we specify to output each file that it compiles and nothing happens. If I use gnatmake.exe It gets stuck at command gcc -c -Ietc\ -I- -x ada etc\makefile where it says there is illegal character and target_name is an Ada 2020 feature. Not sure what any of those mean.
I managed to somehow previously get this to compile before, but since then the PC (Windows 10) had to be wiped and reinstalled. Guys that have set this up are long since retired (before I started) so I am hoping you guys can help me out.

Okay so I managed to get it to work. How, I am not entirely sure. I did wind up editing my commands for linux inside the makefile to have quotes around them because Windows kept removing slashes from the path written in the makefile. Also I provided a path to the Unix utilities and the make.exe to C:\MinGW\msys\1.0\bin instead of C:\MinGW\bin. I also had to add the same path to the $Path variable in Environmental Variable The code compiles now and seems to work after flashing it onto our system. My hope now is the instructions I wrote for anyone else to do this will work and I didn't forget something.

Related

Creating an executable file at Visual Studio Code

I am relatively new in programming using the C-language. So to lay it all out, I am still kind of clueless of what is happening. Now, may I ask why I can't seem to create an exe file and run the code?
Actually, the first time I tried executing it, it worked. However, to make sure that it is working, I repeated it and then it didn't work anymore.
To make things clearer:
I use Mac
Mac OS Big Sur
In this particular case, gcc is the compiler
I also tried using Code::Blocks also prior to this; however, I have similar issues -- after I built and ran my first "hello world" program, it didn't run the same program anymore after it. I also tried reinstalling it, but it still has the same issues.
I'm really frustrated that this is happening because I cannot move on to the next lessons in my class. :(
Thank you very much! I hope someone would help a newbie here. :))
Gcc by default names executables a.out. So you can check if that file has been created by running ls a.out and looking through the results.
If it has been made, you can run it from the command line with ./a.out.
If you want to name the executables something else, then when calling gcc, add the flag -o followed by the name you want. E.g. if you want filename.c to compile to filename.exe, then you would write gcc -o filename.exe filename.c. Then you can run it from the command line with ./filename.exe. I think if you give it the .exe file extension you should also be able to run it by clicking it in the Windows file explorer.

How do you debug C code in visual studio code

If I am to compile my code in the terminal, I would do:
cc -std=c99 -Wall -Werror ....
If I'm to run my code in the terminal I would do:
./testprogram text.txt 1000 1000
The numbers and the text file is significant to the program.
Hopefully that gives some insight into the version of c I'm using and how to execute my program. Now: how do you debug this with visual studio code? I have installed the c/c++ extension.
Every time I try to start debug it asks me to chose between two environments:
c++ (GDB/LLDB)
c++ (windows).
My first problem is that non of those two options are just plain c, but maybe I just don't know better and there isn't much difference. Never the less, I gamble on one of the environment, usually the first one, then I'm asked to pick between:
two gcc-9 build and debug active file,
one gcc build and debug active file,
and defult configuration.
I usually pick the defult config one and that leads me to the launch.json page. I put in my program directory: "${workspaceFolder}/testprogram.c" and error.. :
Unable to start debugging. Launch options string provided by the project system is invalid. Unable to determine path to debugger. Please specify the "MIDebuggerPath" option.
Nothing I've tried so far or any googling have helped so hopefully someone with a lot of experience would be able to help out here. Thanks in advance.

VS2019: Include file as project macro

I got a makefile project for Linux and I want to compile it on Win10 with Visual Studio 2019.
There are some paths to files defined in the makefile as preprocessor defines.
I have to replace the paths by own created files because they are a kind of PLATFORM_HEADER and I have to adapt a new one to Windows. In the code it looks like:
#include PLATFORM_HEADER
The onliest I tried is to add a property sheet to my project and add a macro:
macro page of property sheet But this macro is not found in the project.
Changing the code is not possible because it is third party code and it must be able to become updated at later times without doing changes again.
In other instructions there is noted that a line called 'inherited property sheet' has to be modified in the project. But in VS2019 this line does not exist.
Thank you for your help!
This sort of problem will be handled by your compiler suite. Probably you'll deal this with your build process manager (make, bitbake, cmake...). You can ask it to pass these #defines as argument for the compilation (-D name=definition).
Now you've unlocked the "very most of fun" if you compile something meant for linux on windows since there are many way that can go wrong. You might want to do a full check of your environment variable when compiling and make sure they point to the right system librairies.
Probably it's worth giving a try to the windows subsystem for linux and other bindings / emulator. If you want to preview a week of work's outcome, maybe you can do it in a linux VM? or just get rid of windows one good time for all :)

GBA programming with Visual HAM in C

I am interested in programming for the Game Boy Advance using the Visual HAM IDE in C. However, every time I build a project I get a message stating:
'make.exe' is not recognized as an internal or external command,
operable program or batch file.
I downloaded GnuWin32 and make. Then, inside the ham visual editor I clicked advanced, options and set the directory of the MAKE_MODE (I guess some kind of environment variable) to the directory where the make program is.
Any suggestions on how to get this to work?
I had the same problem. Reinstall the hole vham package to the desired destination from the get-go. You can find it here: www.jharbour.com/gba/ham-280-full-win32.zip
You can't move the folders around. Even if you change the PATH variables this problem will persist.
Find where on your system the make program is in. Probably in cygwin's /usr/bin. Add that path to your system dos path.
Windows with cygwin is a screwed up hybrid system. You probably have three paths going on at once. You have the cygwin one. If you open a cygwin shell and type make I bet it finds the make program. Then if you open a dos shell ( in accessories/command prompts ) I bet it won't find the make program.
You will need to add it. Every version of windows does this differently but it is generally under right click on my computer/properties/advanced/environment variables. You will need to add it there.
And finnally there is the path known to your ide (probably). I don't know HAM, but it looks like you already did whatever they told you.
When you are done you should be able to invoke "make" from the windows/dos command prompt.

Cygwin Gcc - Access

I'm currently on Windows Vista Basic.
I have recently started on Eclipse, and for that I was required to install cygwin.
After that I made an edit in the PATH environment variable in "My Computer>Properties>Advanced Settings". In order to check the functionality, I started cmd-prompt and types
C:>gcc
This gives the following output: ACCESS IS DENIED
I know it's a security permission problem, but I don't know where exactly to do the change in the security settings. Last time I tried it started showing "error-illegal operation" and some error code.
You can not use gcc in your cmd. you must use it in cygwin shell that installed when you install cygwin
You can use gcc without using the cygwin shell !!
But you will probably end up with some configuration problems,
such as not having the correct dll's in the right places.
Another common error that can occur, is if you have multiple instances
of cygwin installed, the search paths get confused and the gcc system
can't find relevant compiler or tries to use the wrong compiler.
All the same this is very possible, I've done it myself hundreds of time,
when testing compilers I have written.
You might want to try invoking 'cc1.exe' for c, or 'cc1plus.exe' for c++,
remember to copy the cygwin dll's into the same directory as cc1 or cc1plus,
Other than that it could be your user account permissions.
Hope this helps.
/Tony

Resources