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

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

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

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

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.

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.

Broken vanity-gen program on OSX [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I can't get Vanitygen to compile.
Is there a way to install an older version of openssl and make (compile) the program with it?
Or can someone who has an older version of openssl simply compile it for me and give me a link for it?
Are there any other ways to get this program to compile for me on OSX?
Thanks.
Can someone please make me a precompiled vanity-gen program on OSX?
You should try here:
http://www.rentacoder.com
http://www.freelancer.com
It would compile fine if only I had a slightly older version of openssl.
You can get any version you like: OpenSSL source code, tarballs.
I can't compile because I have the latest version of openssl.
You should fetch an older version of OpenSSL.
Is there a way to install an older version of openssl and make (compile) the program with it?
Yes, there is!
$ wget http://w.tar.gzssl.org/source/openssl-0.9.8y
$ tar -xzf openssl-0.9.8y.tar.gz
$ cd openssl-0.9.8y
$ ./config shared --prefix=/usr/local/ssl-0.9.8
$ make all
$ sudo make install
You might need to add export CFLAGS="-fPIC", but I don't recall. Do it right before you execute config.
Then, add /usr/local/ssl-0.9.8/include as an include directory; and add /usr/local/ssl-0.9.8/lib as a library directory.
Here's what it looks like on my Debian machine:
$ ls /usr/local/ssl-0.9.8/lib/
engines libcrypto.so libssl.a libssl.so.0.9.8
libcrypto.a libcrypto.so.0.9.8 libssl.so pkgconfig
Are there any other ways to get this program to compile for me on OSX?
OS X is another can of worms (or can be another can of worms). Once you have a version of OpenSSL installed that suites your taste, come back with configuration problems for vanity-gen.
For Mac OS X, I believe you can perform the following:
$ export KERNEL_BITS=64
$ ./config ...
If you don't export KERNEL_BITS, I believe you get a 32-bit configuration by default.

Resources