making the xar utility use expat instead of libxml2 - freebsd

From the xar utilities source code, it looks like it can use either the expat or libxml2 XML parsers
#if HAVE_LIBXML_XMLREADER_H
#include <libxml/xmlreader.h>
#elif HAVE_BSDXML_H
#include <bsdxml.h>
#elif HAVE_EXPAT_H
#include <expat.h>
How do I get it to use expat instead of libxml when I install it using ports?

The current version (1.5.2 as of this writing) requires libxml.
The word expat doesn't even occur in the source code.

Related

copy_to_user undefined in linux kernel version 4.12.8

In my project I am using char driver to communicate between user space and kernel space. I use the function copy_to_user(void user *to, const void *from, unsigned long n) to copy data from kernel space to user space buffer. We can find this function under #include < asm/uaccess.h > header file.
I complied the project using Linux Kernel version 4.4.0-59-generic, Ubuntu OS version 16.04 LTS and its working fine without any error and warning. I get the desired output.
I compiled the same project using Linux kernel version 4.12.8, Ubuntu OS version 16.04.2 LTS and it throws me an warning during compile time WARNING: "copy_to_user" [/home/ldrv1/Desktop/Vijay/code/build/uts.ko] undefined!. When I do insmod of my module I get error as follows insmod: ERROR: could not insert module uts.ko: Unknown symbol in module. I think that #include <asm/uaccess.h> header file is still supported in 4.12.8 kernel version else I would have got fatal error: no such file or directory error while compiling. I tried updating the linux kernel headers using apt-get install linux-headers-$(uname -r) command and I got the following response:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.12.8
E: Couldn't find any package by glob 'linux-headers-4.12.8'
E: Couldn't find any package by regex 'linux-headers-4.12.8'
This OS version 16.04.2 LTS has linux-headers-4.10.0-35.
How do I get rid of this warning? Suggestions and support appreciated. If more information is required please feel free to ask.
You should use #include <linux/uaccess.h> for 4.12.8.
Here is the definition.
In 4.4 some drivers use #include <asm/uaccess.h> whilst the others
use #include <linux/uaccess.h>.
#include <linux/uaccess.h> is preferable, I think.
You should do apt-get update and then apt-get install linux-headers-generic.
The function copy_to_user and copy_from_user defined in asm/uaccess.h . I think you have some issue when you define this function. I wrote the character device driver with some example about data transfer between Kernel space and User space. View my github: my code for reference. Please star if you feel it is helpful for you :). it has small bug in example 3. I am figuring them, but example 1 and example 2 work well
The answer given by Bronislav Elizaveti is correct. If instead of #include <asm/uaccess.h> we use #include <linux/uaccess.h>, then we won't get the warning.
If you still want to use only #include <asm/uaccess.h>, then you'll need to use _copy_to_user instead of copy_to_user (with the same arguments). A simple _ will do the job.

implicit declaration of function 'create_proc_entry'

I'm trying to use the create_proc_entry() function to create a directory under /proc. When I try to compile the code, I get the following error: implicit declaration of function 'create_proc_entry' .
These are the headers I have included in my .c file:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
#include <linux/uaccess.h>
The kernel version on the machine I'm trying to compile for is: 3.10.33-g7954807-dirty
Am i missing any headers necessary to call this method? Or is the method deprecated in my version of the kernel?
/proc filesystem has been refactored in 3.10, the function you are looking for has been removed, you should use the full featured proc_create function family. Note that the signatures are different.
3.10 version:
http://lxr.free-electrons.com/source/include/linux/proc_fs.h?v=3.10
3.9 version:
http://lxr.free-electrons.com/source/include/linux/proc_fs.h?v=3.9
You can find greater explanation of using full featured /proc functions in the book Linux Device Drivers 4, or, if you want shorter solution, check this link (https://github.com/jesstess/ldd4/blob/master/scull/main.c) where you can see how the struct file_operations has been used. You do not have to setup to all fields of the struct.

timed_mutex won't compile under Cygwin 4.8.2 ('timed_mutex' in namespace 'std' does not name a type)

My file test8.cpp is
#include<thread>
#include<mutex>
#include<chrono>
std::mutex mutex;
std::timed_mutex timed_mutex;
When I compile this code
g++ -std=c++11 -pthread -c test8.cpp
it tells me
timed_mutex in namespace 'std' does not name a type
I compile under Cygwin64, gcc version 4.8.2
==================================================================
#Jonathan Wakely
The timed_mutex type is only defined if the platform supports it. The preprocessor conditions in GCC's <mutex> are:
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
which is defined if the platform defines a usable <stdint.h> header, and
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
which is defined if the macro _POSIX_TIMEOUTS is defined to a positive value by the <unistd.h> header.
If the first macro was not defined then you would not be able to use std::mutex either, so it seems that only the second macro is undefined, implying that Cygwin's Pthreads implementation doesn't support the Timeouts features.
The test used to check for the Timeouts feature is similar to:
#include <unistd.h>
// In case of POSIX threads check _POSIX_TIMEOUTS.
#if (defined(_PTHREADS) \
&& (!defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS <= 0))
#error
#endif
int main() { }
You could try compiling that on Cygwin, and checking for the macro yourself. If Cygwin does support the Timeouts features then please report a GCC bug so we can make timed_mutex work on Cygwin.
Edit: For GCC 6 I have added an alternative implementation of std::timed_mutex for platforms that don't define _POSIX_TIMEOUTS. I don't know if that will help on Cygwin or not.

Cannot include freetype headers on Linux

#include <ft2build.h>
#include FT_FREETYPE_H
int main() {
return 0;
}
Here is the compiler output:
In file included from fonttest.cpp:1:
/usr/include/ft2build.h:56:10: fatal error: 'freetype/config/ftheader.h' file not found
#include <freetype/config/ftheader.h>
^
1 error generated.
I follow the official tutorial.
I have the packages installed:
i libfreetype6 - FreeType 2 font engine, shared library files
i A libfreetype6:i386 - FreeType 2 font engine, shared library files
i libfreetype6-dev - FreeType 2 font engine, development files
File /usr/include/freetype2/freetype/config/ftheader.h is there.
If someone out there is struggling, you can try
sudo apt-get install libfreetype6-dev
I think it's better to install pkg-config.
pkg-config will help the configure to find the freetype2.

QtMultimedia inclusion in Windows and Linux

I am using QtMultimedia module in my application. However, the following code, which passes in Windows, fails on ubuntu.
#include <QtMultimedia/QAbstractVideoSurface>
#include <QtMultimedia/QVideoFrame>
according to this question, QtMultimediaKit must be installed. However, the location of headers differ, and code that passes looks like:
#include <QtMultimediaKit/QAbstractVideoSurface>
#include <QtMultimediaKit/QVideoFrame>
It is admittedly a minor difference, but it prevents me from interchangeably compiling in Windows and ubuntu. My guess is, i should use some form of macro expression, in lines of:
#ifdef WIN_MACRO
#include <QtMultimedia/QAbstractVideoSurface>
#include <QtMultimedia/QVideoFrame>
#else
#include <QtMultimediaKit/QAbstractVideoSurface>
#include <QtMultimediaKit/QVideoFrame>
#endif
to make the code compile on both systems. If that is correct, what should the macro be? If not - how can the problem be solved?
There is a macro in the Qt libraries that should help you. Try:
#ifdef Q_OS_WIN

Resources