Is there such a thing as a MSYS script file? - c

I'm running MSYS under Windows and although it works I want to know if there is such a thing as a MSYS script file.
For example to compile a GTK program in C I need to type: gcc source.c -o executable.exe 'pkg-config --cflags --libs gtk+-3.0' to compile. Is there a way to store this in a file and run the file from MSYS without having to type in the command each time (IE like .bat, .sh files)?

If you want to automate building an application, just use a build system. The Meson build system is what the GTK+ developers recommend now (and GStreamer, and many other projects). It's multiplatform, and available as a package in MSYS2 (I used it there, works like a charm). They have a simple Meson tutorial where they build a GTK application. That's 3 lines of code.

Related

16-Bit Error When Developing OpenGL Application on Windows

First, the background information - the question itself follows in bold.
I am trying to learn how to write OpenGL programs on 64-Bit Windows 10 Home (Version 21H2 OS Build 19044.1706). I program using Notepad++ as a text editor, and build via batch scripts and command prompt. I do not want to use an IDE or advanced build tools as I have found minimalistic tools to be easier for me to learn.
My development environment is as follows:
I have downloaded the .zip files for GLEW and freeglut from graphics.ucdenver.edu, and extracted the files to Desktop\Graphics\Dependencies\Glew and Desktop\Graphics\Dependencies\FreeGlut, respectively.
In Desktop\Graphics, I have included the code from https://github.com/TransmissionZero/Hello-GLUT as a test, and I am trying to build it using the following batch script:
#echo off
gcc -c %1.c -o %1.exe -I"C:\Users\myusername\Desktop\Graphics\Dependencies\FreeGlut\include" -L"C:\Users\myusername\Desktop\Graphics\Dependencies\FreeGlut\lib" -I"C:\Users\myusername\Desktop\Graphics\Dependencies\Glew\include" -L"C:\Users\myusername\Desktop\Graphics\Dependencies\Glew\lib" -lopengl32 -lbz2 -Wl,--subsystem,windows -Wall
where I am passing the location of the C program (TransmissionZero\HelloGLUT\HelloGLUT) as the command line argument.
The command succeeds without errors or warnings, but when I run the exe, I get "Unsupported 16-Bit Application" and the example program does not run. How do I resolve this issue?

Problem with seting up gtk for c language

I want to learn gtk to make GUI using c language I installed all the stuff required as per the website installation guide but then I don't know what to do next how to compile the code, I use atom for writing my c code sometimes also dev c++, so can I set up gtk in atom or dev c++ and compile my code and if not is there any good alternatives for compiling gtk code?
If you are using Dev-C++ (that project is ancient BTW, I would suggest moving on from that) I expect you are working in a Windows environment? I would suggest using MSYS2 for compiling GTK applications in Windows:
https://www.msys2.org/
MSYS uses the Pacman package manager for its shell. You will need to download the following package in order to compile GTK applications in MSYS/MinGW:
pacman -S mingw-w64-x86_64-gtk3
You should also download gcc and pkg-config to compile:
pacman -S pkg-config gcc
Note that pkg-config is generally used to compile GTK applications due to the number of dependencies that are required (Glib, Cairo, etc.). I can't imagine you possibly compiling a GTK application using Dev-C++ as a result. You should add the following line to your .bashrc file (this will be located in the home directory of MSYS):
export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH"
A typical compile line for a GTK application would look like this:
gcc -o <program> <program>.c $(pkg-config gtk+-3.0 --cflags --libs) -rdynamic -lm

Build commands needed to run Wine programs from IDE

I’ve recently done a git clone of the wine repository at https://github.com/wine-mirror/wine and downloaded the folders to (~/repo/wine/). I'm trying to run Notepad, but don't know how. I am assuming that to build and compile it, I would need to run main.c from the notepad folder. I’m running GCC v 8.3.0 on Raspbian/Linux 10
With the repo downloaded as shown above, what build commands would I need to run notepad’s main.c from Geanie (or any, currently using Geanie) IDE? Can a single compile and/or build command let me run notepad from Geanie, or am I missing something?
Other details (not needed if what I thought I was going to do can't be done):
I wanted to try to run main.c at (~/repo/wine/programs/main.c), but don’t know how to get GCC to view all of the necessary header files. In my execution instructions window in Geanie, I have
gcc -Wall -c “%f” /home/pi/repo/wine/include
and my build instruction (it won't compile, so this isn't anything I've even gotten to work with yet...)
gcc -Wall -o “%e” “%f” /home/pi/repo/wine/include
When I attempt to compile, I get:
Stdio.h:11:10: fatal error: corecrt_wstdui.h: No such file or directory.
#include <corecrt_wstudio.h>
I went over to the stdio.h and attempted to add a build instruction here as well that also targets the include folder (which is the supposedly missing file), but it won’t compile.
Using cpp -v, I can see my include paths for GCC are as follows:
#include”...” paths:
#include<...> paths:
\usr\lib\gcc\arm-linux-gnueabihf\8\include
\usr\local\include
\usr\lib\gcc\arm-linux-gnueabihf\8\include-fixed
\usr\include\arm-linux-gnueabihf
\usr\include

Install GTK for c on Windows 10?

Can you tell me how to install GTK on windows 10 or have a step by step guide, all the ones I've tried have not helped me.
Possibly if someone also explain how to compile from cmd or prepare an IDE (code: block maybe).
Any commands I mention should be run at the MINGW shell, found here: C:\msys64\msys2_shell.cmd
First update msys2 with pacman -Syu
Make sure you have installed GCC...Install the required toolchain for GCC with pacman -S mingw-w64-x86_64-toolchain. When using pacman, just keep typing enter if prompted to follow through with the installation and get back to the command prompt.
In order to set this step up with Code:Blocks, make sure you go to the Code:Blocks menu Settings->Compiler, and the menu Toolchain Executables. From there, put in the msys2 installation directory and where you installed MinGW's GCC compiler (for me this was putting C:\msys64\mingw64) under the compiler's installation directory option. Also edit the C Compiler path under the same menu to x86_64-w64-mingw32-gcc.exe.
Next, in order to install gtk+3.0, use the command pacman -S mingw-w64-x86_64-gtk3. Now the latest version of GTK+3.0 will have been installed, so it is time to set it up with Code:Blocks.
Open Code:Blocks and create a new C file. You may definitely write your code in Code:Blocks, but I do not suggest that you compile it from there. Two compile, go back to the MINGW shell. Type nano ~/.bashrc to edit it. You may scroll down using the arrow keys to the bottom of the file and add: PATH=$PATH:/c/msys64/mingw64/bin. Restart the MINGW shell and open it back up.
Finally, try running:
gcc source.c -o executable.exe `pkg-config --cflags --libs gtk+-3.0`.
If that command doesn't work, I would suggest using the i686 version of gcc installed in MINGW.
I hope this helps!

mingw to cygwin

I am a newbie in cygwin. However, I have used mingw so far, but it is not supporting fork(), so I need to switch to cygwin. I have created a build.bat file in my mingw (programming language C):
gcc -o mask mask.c -pg -I/c/opencv/build/include -lopencv_core231 -lopencv_highgui231 -lopencv_imgproc231 -L. -L/c/opencv/build/x86/mingw/lib
Can anyone suggest me how I can run this .bat file at cygwin or refer me to a site.
How can I run mingw executable with cygwin? Any refernce will be appreciated.
Thanks for your help
Emon
I believe that cygwin can run cmd (DOS command interpreter), which can then run your batch file. The problem is that cmd won't be able to use the non-windows paths that you have in your batch script. Try to run: cmd /c myBuildFile.bat at a cygwin prompt, and you should see what I mean.
It is better to use cygwin-style tools for making a build script. You should have the make program on your path which will allow you to write simple and more complex build scripts.
Alternatively you could convert your .bat build script into a shell script, something like this:
#!/bin/sh
gcc -o mask mask.c -pg -I/c/opencv/build/include -lopencv_core231 -lopencv_highgui231 -lopencv_imgproc231 -L. -L/c/opencv/build/x86/mingw/lib
Name it anything, e.g. myBuildScript.sh, then make it executable with: chmod u+x myBuildScript.sh.

Resources