Header file missing (ini.h) - c

I'm building a small C project from source (https://github.com/danos/vyatta-route-broker) which has multiple .c and .h files. I run its Makefile and this error occurred:
"fatal error: ini.h: No such file or directory"
It is due to this line in one of its files:
"#include <ini.h>"
There is also "LIBS += -linih -pthread" in the Makfile. I commented out ini.h library in both places, but it is a necessary one and building is impossible without having it.
What is "ini.h"? It is a C standard library?
How can I find it and install it on my system?

I think inih in your case refers to the library inih (INI Not Invented Here), it is a simple .ini file parser. They have a github page https://github.com/benhoyt/inih. Also, if you are using linux, you can search on the package management tool of your distribution. For example, for debian you can get it from this link https://packages.debian.org/bullseye/libinih-dev.

Related

Make clangd aware of macros given from the compiler

I have two executables that are build from the same source (a client and a server) and they're built with the compile options -D CLIENT=0 -D SERVER=1 for the server and -D CLIENT=1 -D SERVER=0 for the client. If I do something like
if (CLIENT) {
// Client specific code
}
clangd complains that CLIENT is not defined. Is there a way to make clangd aware of those macros? (The code compiles just fine, the errors are from clangd, not the compiler)
Is there a way to make clangd aware of those macros?
From getting started with clangd:
Project setup
To understand source code in your project, clangd needs to know the
build flags. (This is just a fact of life in C++, source files are not
self-contained.)
By default, clangd will assume that source code is built as clang
some_file.cc, and you’ll probably get spurious errors about missing
#included files, etc. There are a couple of ways to fix this.
compile_commands.json
compile_commands.json file provides compile commands for all source
files in the project. This file is usually generated by the build
system, or tools integrated with the build system. Clangd will look
for this file in the parent directories of the files you edit. Other
tools can also generate this file. See the compile_commands.json
specification.
compile_commands.json is typically generated with CMake build system, but more build systems try to generate it.
I would suggest moving your project to CMake, in the process you will learn this tool that will definitely help you in further C-ish development.
compile_flags.txt
If all files in a project use the same build flags, you can put those
flags, one flag per line, in compile_flags.txt in your source root.
Clangd will assume the compile command is clang $FLAGS some_file.cc.
Creating this file by hand is a reasonable place to start if your
project is quite simple.
If not moving to cmake, create a compile_flags.txt file with the content for example like the following, and clangd should pick this file up:
-DCLIENT=1
-DSERVER=1

Codeblocks not recognizing tcl library

I am attempting to run an old program that uses tcl as well as legacy opengl. I managed to link the opengl libraries successfully; however, I cannot seem to get the tcl linker to work. For context, the program I am using came with include and lib folder. The lib folder contains tclstub86_32.lib, tclstub86_64.lib, and tkstub86.lib as well as opengl .libs. The include folder contains two folders: tcl_include and tk_include, which obviously contain all the .c and .h files for tcl and tk. The following pictures show my settings from using project -> build options:
The error I receive when compiling is:
C:\Users\amlut\Downloads\C\tkogl\curve.c|18|undefined reference to `_imp__Tcl_Free'|
And here is the bit of code that is throwing the error:
if (*line != NULL) Tcl_Free((char*)*line);
I am not sure what I am doing wrong here, any help is appreciated. Thank you.
The problem is that the code is apparently linking against the Tcl stub library (an ABI/API adaptor library) but isn't compiling to use that library but rather to use a full Tcl library instead. When building an extension package, using the stub library is a good thing as it means that the resulting code is not bound to an exact version of the Tcl (and Tk) library but rather to a version of the Tcl ABI which has a much longer support cycle.
The fix is to define the USE_TCL_STUBS and USE_TK_STUBS (that has the identical issue; you have just hit the Tcl version of it first) C preprocessor symbols when building; set them both to 1 and recompile. This is done under the Compiler Settings tab in Code::Blocks apparently.

Compiling SDL 2 alongside my own source files

Due to a compilation bug I cannot correctly use the SDL dynamically linked, I don't prefer to go with the static linking route as I'm not sure of how well implemented this is in the language I am using.
That's why I would like to compile the SDL 2 source files manually, I simply used the files present under /include and /src in the official repo, but at compile time I get this error:
In file included from /Users/adtrevor/CompileSDL/Sources/SDL/src/video/qnx/video.c:23:
/Users/adtrevor/CompileSDL/Sources/SDL/src/video/qnx/sdl_qnx.h:26:10: fatal error: 'screen/screen.h' file not found
#include <screen/screen.h>
^~~~~~~~~~~~~~~~~
1 error generated.
In file included from /Users/adtrevor/CompileSDL/Sources/SDL/src/video/qnx/keyboard.c:26:
/Users/adtrevor/CompileSDL/Sources/SDL/src/video/qnx/sdl_qnx.h:26:10: fatal error: 'screen/screen.h' file not found
#include <screen/screen.h>
^~~~~~~~~~~~~~~~~
1 error generated.
In file included from /Users/adtrevor/CompileSDL/Sources/SDL/src/video/qnx/gl.c:23:
/Users/adtrevor/CompileSDL/Sources/SDL/src/video/qnx/sdl_qnx.h:26:10: fatal error: 'screen/screen.h' file not found
#include <screen/screen.h>
^~~~~~~~~~~~~~~~~
1 error generated.
I know it is possible to do that since the official website mentions it, but I don't know at all what steps I should follow in order to make it work correctly?
EDIT :
Here is the sample repo: https://github.com/adtrevor/compileSDL
SDL is a cross-platform library, and its unlikely that you want to compile all of the source files in order to get the functionality that you need. Usually you run configure / make, and it will make the decisions on what to build/not build.
You mention that you are building the source files yourself; so you may want to obverse the SDL build and try to capture the same files. In regards to your error, QNX is the Blackberry operating system-- so depending on your use-cases you can avoid building everything under SDL/src/video/qnx/* since you don't have those operating system headers anyway.
SDL should build the static libraries by default anyhow. Consider doing a regular build and using sdl-config --static-libs to find out which static libraries you should link with.

Adding the crypt() library to a C program in Windows 10 cmd prompt

I have written a C program 'hashed.c' which requires the use of the crypt() function to carry out the hashing of various words.
I have downloaded the GNU C library from an online source (http://ftp.gnu.org/gnu/glibc/) which contains the crypt library I need along with a number of other libraries. I have extracted all of the contents of the GNU C library to the same directory that my 'hashed.c' program is located in.
This directory is located in C:\test\.
In my program code I have included the header file
#include <crypt.h>:
However when I attempt to compile the program using
cl DAnew.c
I receive an error message saying:
Cannot open include file 'crypt.h'. No such file or directory
The crypt.h file is located in C:\test\crypt\ and so I have changed the command line to:
cl DAnew.c /I C:\test\crypt
to directly link the crypt.h file. However I now receive the error:
Cannot open include file 'features.h'. No such file or directory.
The 'features.h' file it is referencing is located within the same directory at:
C:\test\include\features.h
Would anyone be able to show me how to correctly link the crypt library (as well as the others libraries needed) to my C program please?
I have downloaded the Visual C++ build tools and I am using the 'Visual C++ 2015 X86 Native Build Tools Command Prompt'.
Many thanks for your help.
cl DAnew.c /I C:\test\crypt;c:\test\include
Your compiler knows where to find it's standard includes but does not know where your custom includes are located. It must be informed about all of them.
By the way, this is not linking the crypt library. This is setting the search path for custom include files You will have much the same effort when you attempt to link with the crypt library. The above information should be enough to get you started on that path.

How do you configure XCode to find header files and symbols in an "External Build System" project

I'm trying to set up an XCode 5.1 project for C php-extension development. This is essentially a GNU autoconf/automake project with one prerequisite step.
I created a new "External Build System" project. I then made two targets, one that runs the prerequisite "phpize" command that creates GNU autoconf files. I have another target that runs the GNU ./configure script. This all works great.
Next, I tried adding my .c and .h files to the project. When I open them, and try to click on any #include .h file or any external symbol, XCode says "symbol not found", even for system stuff like <stdio.h>.
In a normal XCode project, there is a way to configure the header/include search paths. With this external build system project, I see no way to do this.
My questions:
For a project that uses ./configure and make, is the "External Build System" project type the correct type?
If so, then in this project type, how do I set the header/include search paths so that code navigation works?
Analyze doesn't seem to work right, either.

Resources