including wpa_ctrl.h in a C code - c

I would like to add wpa_ctrl.h on a C code, and the source code has the following header files:
#include "includes.h"
#include "common.h"
how do I suppose to have them? Do I need to install any package or do they suppose to be at the kernel header files or in the include path? If I need to include it manually, then each file depends on some many header files that needs to be added manually, is there a convenient way to add the files that are needed

These files are part of the hostapd project, and internal header files that won't be installed so you can't just include them after installing the package.
You'd be probably better off just ripping out the parts from wpa_ctrl.h you need. Depending on what you need it might be even better to use e.g. the DBus interface to communicate with wpa_supplicant (if that's what you want).

You get them from wpa_supplicant source code.
Here's where to find them:
wpa_supplicant-2.4/src/utils/includes.h
wpa_supplicant-2.4/src/utils/common.h
I copied them into my project directory and everything worked.
Here's where to find the source code:
https://w1.fi/releases/

Related

Static library header file

I am trying to import a static library based on Hierarchical Matrices (H2Lib). The folder contains a make file which compiles the library files, examples and tests into a single .a file. I have referred to tutorials on creating and using static libraries in C using archiver command line in Linux but this does not create a header file, which I had to create manually while working out the tutorial. The H2Lib has multiple files and it would be difficult and time consuming to create a header file manually for this. I am not sure if I am missing something here or doing something wrong; I am new to the concept of libraries in C. Can some one please help me on how to use this library in C?
P.S: git repository link for H2Lib: https://github.com/H2Lib/H2Lib/tree/master
You are not supposed to write the header files yourself. Somewhere on the folder where the library is defined there should be a directory with multiple .h files (the headers) (it's usually named include).
What you need to do is include them into your project. You do this by appending -I to the path of each folder containing the headers and then writing #include "headername.h" in your source code.
So if the headers are in dir/include, you'd do:
gcc yourfiles.c <flags> output.o -I dir/include

What is xutils.h, and what cflags/libs/packages do I need?

I am thinking about maybe creating my own modified version of a GTK2 libwnck widget. In the source files of these widgets, it includes a file called xutils.h. This header file is present in GNOME's libwnck git repository, but it is not present in my distro's libwnck header files.
I have tried searching for an xutils package for Arch Linux, but I cannot find such a package. I also looked in Fedora's libwnck header files, and that does not have an xutils.h file either.
Here are my questions:
What cflags/libs do I need in order to use this header file, or else what packages do I need to install?
Why is the xutils.h file not present in my distro's libwnck header files?
This program should be able to be linked against a distro's stock libraries. Potential users should not be expected to download and compile other libwnck source files.
Please note that the header file I am looking for is called xutils.h (with an "s"), not Xutil.h.
I don't claim to know anything, but a quick google suggests that xutils.h is related to the X11 client side library, and that it comes with the libx11 package on Arch.
This google link xutils.h still hints at an X11 related function, and it is interesting that the guards on the file are WNCK_XUTILS_H

Doxygen is confusing a project file with a system library file with the same name

I have a large C project, with multiple directories and subdirectories, that I'm trying to document with Doxygen version 1.7.6.1-2ubuntu1.
My problem is that the project has a file (string.h) which Doxygen is confusing with the system library include file of the same name. In the project code, the project file is included with #include "lib/string.h" and the system file is included with #include <string.h>.
However Doxygen always references the project include file, regardless of which of the two #include forms is used. (And since the project string.h happens to include the system string.h, Doxygen actually shows a self-referential dependency in the dependency graph!)
How can I configure Doxygen to take notice of whether #include "..." or #include <...> has been used, and not match the project file in the latter case? It's not a practical proposition to rename the project file and change all of the other files that use it.

How do I use a compiled binary for a C library on Linux?

I downloaded the libftp source from here, and compiled it using make. Now I just have a binary called "ftp" in the same directory. Do I need to move it to one of the root directories, like /usr/bin? Do I still need the source files so that I can #include the library?
To use a library in your own code, first you need that library - generally named lib{name}.a or lib{name}.so. The library will be required during linking. So when you make, make sure it creates the library and not just the ftp binary.
Secondly, at compile time you will need the header files so that the #include's don't throw errors. So as far as source goes, you will at least need the header files.

Add one header from a different project to my project using automake

I'm working on a relatively big project that is using automake build system.
Now the problem is that I need to link the project with a library from another project (this works fine), but I also need to include a header from the other project source tree (api.h).
INCLUDES = -I#REMOTE_PROJECT_DIR#
in Makefile.am doesn't work, because there are .h files with coliding names in the remote source directory. How can I add just the api.h?
I used a symlink into the include directory in the project, but now I need to push the sources into a public repo and everyone working with it has the other project in a different directory, so I need to use the configure param.
You do not want to tweak you Makefile.am or your configure.ac in any way. If api.h is installed in a standard location (eg /usr/include), then all you need is AC_CHECK_HEADERS([api.h]) in configure.ac. If api.h is installed in a non-standard location (eg /home/joe/include), the way to pick it up in your project is determined at configure time. When you run configure, you add the argument CPPFLAGS=-I/home/joe/include to the invocation of configure. You do not indicate the non-standard location in the build files themselves.
Another alternative is to use pkg-config, but the non-standard location of your header file will still be dealt with when you run configure. (This time by setting PKG_CONFIG_PATH rather than CPPFLAGS)
If you have headers with same names, you could put at least one of them into directory with different name and include it using directory name.
Here's a sample directory structure:
mylibrary/include/myblirary/api.h
myproject/api.h
myproject/main.cpp
In main.cpp:
#include "api.h"
#include "mylibrary/api.h"
#include <boost/regex.hpp>
When compiling:
g++ -I mylibrary/include

Resources