Click here to Skip to main content
14,977,142 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
When i runthis code igot an error for mqueue.h how can i run this program
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <mqueue.h>
#include <unistd.h>

#include "../../src/UUGear.h"

int main(int argc, char **argv)


    UUGearDevice dev = attachUUGearDevice ("UUGear-Arduino-7853-2668");

    if (dev.fd != -1)
        int pin = 3;    // analog input pin 3

        int i, value;
        float voltage;
        for (i = 0; i < 100; i ++) {
            value = analogRead(&dev, pin);

            voltage = (float)(value * 5) / 1024;

            printf("%.2fV\n", voltage);


        detachUUGearDevice (&dev);
        printf("Can not open UUGear device.\n");


    return 0;
Updated 9-Jul-15 4:01am
Dominic Burford 9-Jul-15 7:31am
What is the error message? What line of code is throwing the error? Have you stepped through the code to see what's going on?
chandanadhikari 9-Jul-15 7:43am
the code is not able to find 'mqueue.h'. It can find the other header files like stdlib.h and stdio.h in the proper location and can hence use the code inside these header files, but it can not do the same for mqueue.h.
So, either mqueue.h is not present on the machine at all
it is at a location on the machine about which the compiler does not know(in this case you need to tell the compiler where exactly to find the header file).

You can search for mqueue.h on the system, and mention its full directory path as you have done for UUGear.h. Check if it works !!
markkuk 9-Jul-15 7:46am
What OS and compiler are you using? mqueue.h is a Unix/Linux header and it probably won't exist in Windows systems.
Stefan_Lang 9-Jul-15 11:22am
Looking at the third line of functional code my guess is he's programming Arduino ;-)

[edit] I have to correct myself - I wondered about said line and googled to find out what it is good for. I stumbled upon this Raspberyy PI project:

This appears to be the source of the code, but it doesn't say where to get mqueue.h . I suspect, as you say, the Raspberry PI is running some Linux distro.
You cannot. :-)

Go back to where you got the code from, and look for the headers and library files it need to work: it looks like you have just grabbed a bit of code and expect it to work in isolation.

mqueue.h is a header file, probably for a required library.
Looks like you got that code from here:[^]

If so, the code is supposed to run on a Raspberry PI sporting some Linux distro. If you're trying it on some other OS or platform it probably won't work.

If you are in fact trying to make this run on a Raspberry PI using Linux, and it still doesn't work, then maybe you're missing an include path. In that case search the file and add the file location to your include path.

Otherwise you can try and contact the author: he left a link to his homepage at the bottom of the site posted above.
veena nair 10-Jul-15 2:59am
Ya it is. Can u please help me to find the device id and how to a add to python program. i dont know nothing about python. i opened the but i dont know how to add the device id to it now when i run that program it is showing that "UUgear device is not correctly initialized . here is the code

from time import sleep
from UUGear import *


device = UUGearDevice('UUGear-Arduino-7853-2668')

if device.isValid():
for i in range(100):
print "%0.2f" % (float(device.analogRead(3)) * 5 / 1024), "V"

print 'UUGear device is not correctly initialized.'
Stefan_Lang 10-Jul-15 3:44am
Sorry, I don't know python myself. If you have questions regarding the python code, you can either try to contact the author, or post a separate question with the tag 'python'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900