How can I compile .C to .exe and edit the view? [closed] - c

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I wrote 2 programs in C (one encoder and one decoder with random encryption key every second) and I want to compile those 2 programs to .exe to publish it.
Can you please help me how to compile it?
I tried with Visual Studio and Pycharm with tkinter. But it's like a totally new language for me. In Linux I compiled it via terminal to .exe.

To compile to .exe open the command prompt and type this:
gcc fileName.c - compiling and linking, produces a.exe
or
gcc -c fileName.c - only compiling, produces fileName.o object file
gcc -o test filename.o - linking and produces test.exe
If there are more than 1 source file you can do the just compiling part for all files and generate object files.Then do the linking by adding their names in the command.Of curse this is applicable if there are less files but for a bigger project you have to write a makefile.

You are searching for a compiler, like GCC or Clang. If you are developing on Windows, I recommend MinGW (GCC for Windows). Then you can compile and link your source code to an .exe file using the commandline, just like you did on linux.
Your IDE (like Visual Studio) is basically doing the same, you just don't see it. If your IDE is configured properly, it should work just fine.

Related

How to build/install libcurl on windows with MinGW [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 months ago.
Improve this question
I have installed MinGW-w64 with MSYS to compile a project I built on Linux on Windows. I do not want to use MSVC, though I did find info on how to build libcurl with it. On Linux I just installed libcurl with "pacman -S libcurl" and could do.
#include <curl/curl.h>
...
I tried to install the precompiled libraries for windows from https://curl.se/windows/ but I have no idea where to put the files from "include" and the files from "lib"
EDIT
I checked https://curl.se/download.html and it seems like I only need the headers and not the all the binaries since curl is already installed on Windows 10. However the only ways there seems to be to install libcurl header files is either with vcpkg which I do not really want to use and cygwin which seems redundant because I have MinGW-w64 installed. Is there a way to install the libcurl package without vcpkg or cygwin.
I found a solution! On MSYS2 just do "pacman -Sy mingw-w64-x86_64-curl" which installs the binaries and the header files. The info was here https://everything.curl.dev/get/windows/win-msys2 and I have no idea why this is not in the curl downloads page or why MinGW on MSYS is not mentioned at all.

missing library "jansson_private_config.h" in Jansson c parser library [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
Anyone ever used jansson C-parser for parsing JSON objects. I was trying to study the library, for same I compiled it with the sample program given with it. Added the header files required but one header file is missing named "jansson_private_config.h" I have downloaded this library completely I am not sure where I can get this ??
You can find in documentation how to build this library for windows:
Get CMake and Visual Studio
unpack source
In a command line
cd .../jansson-2.12
mkdir build
cd build
cmake -G "Visual Studio XX 20XX" ..
You should be done
Alternate method
You can also edit manually the jansson_config.h.in, ommitting to define HAVE_CONFIG_H which cause the jansson_private_config.h to be included in .c files.
Note that this #ifdef HAVE_CONFIG_H test has been forgetten in test_dump.c, which won't compile if you don't fix it.
Fix proposal (not tested):
+#ifdef HAVE_CONFIG_H
#include "jansson_private_config.h"
+#endif

I got stuck with my first code in C programing language, I cannot make an excutable file? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I used to compile and run C codes in windows OS using code block program, at the mean time, I am using LINUX OS (Ubuntu 14.10 LTS)
I've created a simple program (hello ,world!). This is the code
#include<stdio.h>
int main(void)
{
printf("Hello! This is a test prgoram.\n");
return 0;
}
Its name is demo.c
When I try to make an executable file demo via:
gcc demo.c -o demo
I cannot get a green executable file!!!!!!!!!!
When I try
./demo
I get
bash: ./demo: Permission denied
for more informations, I have posted the outputs of some command in the following link
https://unix.stackexchange.com/questions/259982/error-while-compiling-my-first-program-in-c-language?noredirect=1#comment451370_259982
From the output of the various commands in your other question, it looks like you are using a file system that does not respect or store file permissions (is this an NTFS partition used by Windows and you configured the machine for dual boot?).
Try working in a directory that is on a native Linux file system, for example your home directory.
bash: ./demo: Permission denied
Just ensure your executable is created and then Change permission by doing
chmod u+x <executable name>
This will give the x - "execute" permission for the "owner" - u of the file, which should be enough to execute the file, provided it is an executable.

Eclipse: debugging large C project without compiling in Eclipse

I have large C project which I'm compiling manually and then debugging via GDB.
I'm already editing source in Eclipse, but I am not able to compile it there, because of complex and multiple makefile.
Is it possible only to launch app via Eclipse for debugging as via GDB?
Thanks
Yes, you can just set up the debugger to point to the binary and have it launch it. Just make sure you compile it with the right flags (-ggdb and -g3 for symbols). If you have it imported as a Makefile project, it should be able to automatically map your code to the symbols.
Basic instructions are here: http://eclipse.org/jetty/documentation/current/debugging-with-eclipse.html

how to compile programs with .a and .h extension [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Using osx how do I run a program I got on the internet that comes with a .a and another file that comes with a .h file.
I'm using a mac terminal.
File with .a extension is an archive library and File with .h extension is a header file to expose the internals of the library.
These files cannot be run!
You need to include the header (.h) in your source and link the library (here ``libx) using e.g.
gcc -o myprog myprog.c -L/path/to/libx -lx

Resources