Accessing libnetlink.h - c

I'm trying to access some member variables within libnetlink.h, but when I #include in my source and compile with "gcc source.c -o binary", I get a "fatal error: libnetlink.h: No such file or directory" error.
I'm on Ubuntu 16.04 and I've already installed libnl-3-dev via apt-get install.

You need to put the correct path that must be seen from your source file.
this can be done by either:
1: Full path of the file 'libnetlink.h' like this (for example in linux):
/home/username/Desktop/folder1/libnetlink.h
2: Relative path of the file, corresponding to where your source file exist:
suppose your source file exist on 'Desktop', and your libnetlink.h exist in sub folder of Desktop folders called 'folder1', then the path will:
folder1/libnetlink.h

I guess the following command may help.
apt-get iproute-dev
I am using Fedora Core 26, after installing iproute-dev, the same problem is solved.

Related

Python script to fetch an executable file from local repository git

I have an access to the local repository (git) of my company with this url -> "gitolite#10.10.10.55:/Intel/BareRepos/lteue.git" and my python script need to execute any file (.c & .h files) of this project and create a binary. After which the script has to run this binary file.
The code which I have wrote is:
import os
os.system("git clone gitolite#10.10.10.55:/Intel/BareRepos/lteue.git")
os.system("cd /home/saicharan/Documents/lteue")
os.system("gcc somefile.c")
os.system("./a.out")
I am getting the error like this
gcc: error: helloworld.c: No such file or directory
gcc: fatal error:no input files compilation terminated.
sh: ./a.out: No such file or directory
Please help me out with this.
Fortunately I got the solution for this:
os.system("git clone gitolite#10.10.10.55:/Intel/BareRepos/lteue.git")
os.chdir("path/to/file")
os.system("gcc path/to/file/somefile.c")
os.chdir("path/to/file")
os.system("./somefile.out")
and its working fine.!
You can make it even more simpler.
import os
os.system("git clone gitolite#10.10.10.55:/Intel/BareRepos/lteue.git")
os.chdir("path/to/file")
os.system("gcc path/to/file/somefile.c && ./somefile.out")
It Works.!

CLIPS compilation

I would like to compile CLIPS on Windows to get object files necessary to a binding with GNAT Ada.
I have downloaded the package clips_core_source_630.zip which provides core & makefiles directories
makefile.g++
makefile.gcc
makefile.lib
makefile.lib++
makefile.win
I tried to compile with MinGW through the commands :
mingw32-make makefile.gcc
or
mingw32-make makefile.g++
But the answer is always : Nothing to be done ! And of course no object file has been generated.
What am I doing wrong with that approach ?
Normally the argument to a make command is the desired target, not the name of the Makefile.
Since the file given as an argument already exists, there is nothing to be done.
If you want to build the project, try just a simple mingw32-make in the directory containing the Makefiles.
If that doesn't work, you can specify the file with -f.
mingw32-make -f makefile.g++

libqrencode - Segmentation fault couldn't read "qrspec.c"

I previously made this question and got a light at the end of the tunnel by the response that I got. But now that I found the problem, I don't understand it. I don't have root priv. Whenever I run the program I get segmentation fault and a core file. When I analyse it with dbx I get this
reading symbolic information ...
Segmentation fault in QRspec_newFrame at line 546 in file "" ($t1)
couldn't read "qrspec.c"
How come he can't find qrspec.c if that file was included on the process of generating the lib? (I wasn't involved on that process so I have no idea if it went 100% but I gave the .tar with all the files). Also that file belongs to libqrencode.
Compiling:
xlc_r7 -g qrgen.c -lqrencode -L/usr/local/lib -I/usr/local/include
I'm starting to bealive it can't find the file because there is a .so symbolic link missing on the /usr/local/lib folder. Could that be it? (Only .a , .la and .so.3 in there)
I think my problem is similiar to this one but I can't install the lib again unless that is the real problem.
Machine: Unix AIX powerpc model: IBM,9117-MMB
xlc version: 12.01.0000.0000
I'm guessing you need to tell dbx where to find your source files
From man dbx
-I Directory
(Uppercase i) Includes directory specified by the Directory variable in the list of directories searched for source files. The default is to look for source files in the following directories:
* The directory the source file was located in when it was compiled. This directory is searched only if the compiler placed the source path in the object.
* The current directory.
* The directory where the program is currently located.
I found the problem... The installation of the lib generated problems and caused the symbolic links to exist as a simple file and the library just wasn't there...
This is the missing file "/usr/local/lib/libqrencode.so.3.4.4" which is the code itself... I was looking at the files and didn't notice it because there was a file called libqrencode.so.3.4 but this file was supose to be a symbolic link to libqrencode.so.3.4.4 since libqrencode.so.3.4.4 didn't exist, instead of the symbolic link failing, it created a empty file with that same name...

Compiling C code with external library references

I am on RHEL 6.0 and got hold of the source code for join command(hopefully from the right source!!). I rarely work on a C code and hence finding this difficult. I am trying to compile and run the C code for join, but running into compile time errors.
g++ join.c
join.c:19:20: error: config.h: No such file or directory
join.c:25:20: error: system.h: No such file or directory
join.c:27:25: error: hard-locale.h: No such file or directory
join.c:28:24: error: linebuffer.h: No such file or directory
join.c:29:24: error: memcasecmp.h: No such file or directory
join.c:30:19: error: quote.h: No such file or directory
join.c:31:21: error: stdio--.h: No such file or directory
join.c:32:22: error: xmemcoll.h: No such file or directory
join.c:33:21: error: xstrtol.h: No such file or directory
join.c:34:22: error: argmatch.h: No such file or directory
Since I am not aware of where to find these libraries(I did google for each one and they are spread all over different websites), can anyone please guide me as to how I can link these libraries together and compile the source code of join command?
This is not a linking problem as you suggest. Instead, you get these errors because g++ can't find these files: config.h, system.h, ..., that are #included (indirectly) by join.c.
What you could do is find these files on your system, and then add as many -I<directory> options behind the g++ as there were directories you found these files in. Do man g++ for more info.
You'll also need to find the where the libraries are you need to link against. So you'll need to specify more than -I's.
On the other hand, aren't there 'configure' or other package files? Normally you don't have to specify compiler flags (like this -I) by hand. Instead, it's common that for example Makefile's are generated from such a configuration file, after which you just have to type make.
I advise you to get someone that has done this before, because you don't seem to understand the basics of C program compilation. This can cost you a lot of your precious time without results. But good luck anyway!
Perhaps you don't have everything in place to compile your code. Try installing the build-essential package.
sudo yum install build-essential
On a relevant note, I'm not aware of the script join.c but if you are looking for a way to concatenate a bunch of files together, you can do cat FILE1 FILE2 FILE3 > BIG_FILE where FILE1 FILE2 FILE3 are the files you want to join them. Under RHEL 6.0, you can use asterisks too, if there is a pattern. For example, cat FILE.00* > BIG_FILE

Installing a new library in Linux, and accessing it from my C code

I am working on a project which requires me to download and use this. Inside the downloaded folder, when extracted I am presented with three things:
A folder called "include"
A folder called "src"
A file called "Makefile"
After some research, I found out that I have to navigate to the directory which contains these files, and just type in the command make.
It seemed to install the library in my system. So I tried a sample bit of code which should use the library:
csp_conn_t * conn;
csp_packet_t * packet;
csp_socket_t * socket = csp_socket(0);
csp_bind(socket, PORT_4);
csp_listen(socket, MAX_CONNS_IN_Q);
while(1) {
conn = csp_accept(socket, TIMEOUT_MAX);
packet = csp_read(conn, TIMEOUT_NONE);
printf(ā€œ%S\r\nā€, packet->data);
csp_buffer_free(packet);
csp_close(conn);
}
That's all that was given for the sample server end of the code. So I decided to add these to the top:
#include <csp.h>
#include <csp_buffer.h>
#include <csp_config.h>
#include <csp_endian.h>
#include <csp_interface.h>
#include <csp_platorm.h>
Thinking I was on the right track, I tried to compile the code with gcc, but I was given this error:
csptest_server.c:1: fatal error: csp.h: No such file or directory
compilation terminated.
I thought I may not have installed the library correctly after all, but to make sure, I found out I could check by running this command, and getting this result:
find /usr -iname csp.h
/usr/src/linux-headers-2.6.35-28-generic/include/config/snd/sb16/csp.h
/usr/src/linux-headers-2.6.35-22-generic/include/config/snd/sb16/csp.h
So it seems like the csp.h is installed, maybe I am referencing it incorrectly in the header include line? Any insight? Thanks a lot.
The make command is probably only building the library, but not installing it. You could try sudo make install. This is the "common" method, but I recommend you to check the library's documentation, if any.
The sudo command is only necessary if you have no permissions to write the system's include and library directories, which may be your case.
Another possibility (instead of installing the library) is telling GCC the location of the library's source code and generated binaries (by means of the -I and -L options of the gcc command.
That Makefile will not install anything, just translate the source into a binary format.
The csp.h in the Linux kernel has nothing to do with your project, it's just a naming collision, likely to happen with three letter names.
In your case, I would presume you need to add the include directory to the compilation flags for your server, like gcc -I/path/to/csp/include/csp csptest_server.c.
(Next, you'll run into linker errors because you'll also want to specify -L/path/to/csp -lcsp so that the linker can find the binary code to link to.)

Resources