How to open a .bat (batch file) in gcc (ex cygwin)? - cygwin

How do i open a batch file .bat file in GCC compiler ? what is the command to open it ? we use gcc for c programs to compile. But what is the command to open a .bat file ? Can we open it if so how?

Just run system("example.bat"); Hope it will resolve the problem

.bat files have nothing to do with C programs... So the C compiler has no need to compile it.

Related

WSL + Scons: No such file or directory

I'm using WSL and SCons for cross compiling with arm-none-eabi-gcc. When I try to build I get: "scons: *** [target] No such file or directory", where "target" is the name of the object file to build. The same build is working on our build machine (Arch Linux) and if I compile manually it also work fine. So obviously SCons can't find the source code, but why?
I suspect that scons is not able to find 'sh' rather than the object file. Make sure that you aren't editing env['PATH'] anywhere in your build scripts?

Linux Running executable by linking prebuilt libraries from terminal

I have a folder containing executable (named sd) and also some prebuilt libraries like libbortqt-6.9-qt2.3.so , libpng.so.2 etc . When I run program sd by typing ./sd in terminal , it give me error
::: libborqt-6.9-qt2.3.so: cannot open shared object file: No such file or directory
can anyone suggest me how to solve it
Try doing
export LD_LIBRARY_PATH=.
./sd

cygwin does not create a.out file when I compile for ocaml

I'm currently trying to start learning ocaml with cygwin, but when I try to compile an ml file, nothing happens - no error messages and no files created.
The command I used on cygwin was,
$ ocamlc hello.ml
According to my Prof., there should be a file called, a.out created on my working folder, but there was nothing.
But when I tried with this command,
$ ocamlc -o a.out hello.ml
a.out file was created properly, and I could run the compiled program using
$ ./a.out
as pointed out by the Prof.
For some experiment, I typed in the following,
$ ocamlc -o a hello.ml
This created a file named 'a' without any file extension.
So my question is,
1. Why doesn't it create the a.out file in the first place? - it should have been done according to the Prof.
2. What does the .out file do?
Any new file created when you type ocamlc hello.ml? Maybe camlprog.exe around? If it is, you are using MinGW OCaml over Cygwin. MinGW OCaml is a windows app therefore its default executable file name is not a.out, which is the default name for Unix and Cygwin.
I never recommend ppl to learn OCaml with Windows or Cygwin. Since there are 3 flavors: Cygwin OCaml, MinGW OCaml and MSVC OCaml and they behave slightly different like this. And newcomers are never sure which flavor they are actually using.

Cygwin g++ does not allow ./file on windows 8

When I compiled a program on cygwin like the following
g++ -o helloworld helloworld.cpp
An executable helloworld.exe is created. However, I could not execute the program by using
./helloworld
but instead I need to use
./helloworld.exe
Is there a way to enable the cygwin to recognize helloworld as an executable for the file helloworld.exe
This isn't directly related to g++.
Windows requires executable files (of the kind generated by a compiler, not batch files) to have names with a .exe extension; that's how the OS recognizes them as executables.
Cygwin, as you know, implements a POSIX-like layer on top of Windows. POSIX systems (UNIX, Linux, et al) do not require any special suffix for executable files; the OS recognizes a file as executable based on a "magic number" in the file itself and the executable bit in its directory entry.
To bridge this gap, Cygwin treats the .exe extension separately. Compilers like g++ generate executable files with the .exe suffix, but Cygwin lets you execute a file named helloworld.exe by typing either ./helloworld.exe or ./helloworld. (This even applies to other operations; ls -l helloworld will show you information about helloworld.exe -- assuming there's not also a file named just helloworld.)
In this case, based in information you've provided in the comments, you apparently have two executable files in your current directory, helloworld.exe and helloworld.
I'm not 100% sure what Cygwin will do in this case, but the solution is to delete the helloworld file and make sure that your executables have the required .exe extension. Cygwin compilers will do this for you by default; even if you run
g++ helloworld.cpp -o helloworld
it will generate an executable file named helloworld.exe.
I don't know what you did to create an executable file without the .exe extension. Whatever it was, don't do it again.

if not gcc -static then shell says 'no such file'

I do not know why, but the (Android ADB) shell says no such file or directory when I compile with arm-linux-gnueabi-gcc without the -static option, and then attempt to execute the native executable. This is the no such file or directory you get when the shell knows the file exists at that path, but doesn't want to give the user permission to know the file exists. (e.g. you can check with chmod 4755 which returns no error message).
If I compile with the -static option then the program executes normally.
Why does this happen when compiling without the static option?
if you link statically everything the program needs will be built in. There are no
dependencies to libraries on your device, so it will run perfectly. Bad is the size
of this programming style (huge)!
If you leave out the -static your compiler assumes dynamic linking, but without some
magic you link against (Linux)-glibc: crash!
Search for "native C on Android" tutorial on the net, please. They explain all
the (horrible) linker-stuff you nee to link against Android)-glibc aka "Bionic".
Good luck
may the sources be with you
Martin

Resources