I am trying to compile a c++ project.
I get an error that mutex.h is missing.
1) Where in linux in read hat all include are ?
2) Where do I include it in eclispe ?
Spasiva
You don't mention which type of mutex you are trying to use:
If it's the pthread mutex, then:
#include <pthread.h>
If it's the C++11 mutex, then:
#include <mutex>
(you'll also need to compile with -std=c++11).
Related
I'm using QtCreator 3.3.2 on Ubuntu 14.04(i386), and Qt4.8.6.
The problem is just like what the title said and with a similar error:
'sleep' was not declared in this scope.
And these are headers included.
#include <QMessageBox>
#include <QDateTime>
#include <QDir>
#include <QDate>
#include <QTime>
#include <QFileDialog>
#include <QTextStream>
#include <QStringList>
#include <QFile>
#include <QIODevice>
#include <QFileInfo>
#include <QtGlobal>
Weird thing is there were no problems when I used Ubuntu 12.04 and QtCreator2.4.1(Qt4.8.0);
You should use nanosleep which is available in #include <ctime>.
Also you might need to include unistd.h for sleep and so on which I do not recommend.
All I can think of is that in your previous installation these files were auto included or macro'd.
nanosleep or man nanosleep
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.
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.
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
I am trying to compile a driver. Version of my kernel is 3.2.0-27-generic.
I left only includes that I need:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/dmi.h>
These headers are found. But when I try to compile I get error that asm/cache.h file is not found.
When I dug dipper I found that there is no such folder as "asm", but asm-generic and it contains required headers.
It's structure of folder with headers:
Why was it renamed? Because of it I can't compile another drivers. If I rename "asm-geneic "to "asm" it will lead to other missing headers. What's wrong here?
asm/cache.h is architecture dependent, there are different asm directory for different architectures
arch/powerpc/include/asm/
arch/x86/include/asm/
arch/arm/include/asm
[...]
You can't rename include/asm-generic to include/asm because your problem is that you can't reach the architecture asm folder. Try to check your .config file or set manually the ARCH variable.