Fatal error: rtl.h: No such file or directory

Hi sir,
I am using the image “Emlid-Raspbian-RT-FEB-2015.img” for testing in Raspberry Pi. When I compile the example code, I got error message “hello.c:1:17: fatal error: rtl.h: No such file or directory”. Would you help to solve the issue?

Thanks,
Yi-che

Here is my code:

Hello,
Could you please specify what exactly are you trying to compile?

it is only “hello word” example from internet. Is there anything wrong?

#include <rtl.h>
#include <time.h>
#include <pthread.h>

pthread_t thread;

void * thread_code(void)
{
        pthread_make_periodic_np(pthread_self(), gethrtime(), 1000000000);

        while (1)
        {
                pthread_wait_np ();
                rtl_printf("Hello World\n");
        }

        return 0;
}

int init_module(void) 
{
   return pthread_create(&thread, NULL, thread_code, NULL);
}

void cleanup_module(void) 
{
   pthread_delete_np(thread);
}

This code does not look like a complete Linux code - at least there’s no main() entry…

If you want a hello world program, here’s the one:

#include <stdio.h>
 
int main(void)
{   
    printf("Hello world!\n");
    return 0; 
} 

Save it as helloworld.c and then compile with:

gcc helloworld.c -o helloworld

To run it type:

./helloworld

If you would like to learn Linux C/C++ programming I’d recommend to start with beginners courses like this:

Thanks you for quick reply. Actually, I would like to try the real-time Linux. The Hello world is a test code. Does the kernel support real-time Linux or anything I need to install?

Thanks,
Yi-che

The code you’ve found is probably for RTLinux - RTOS with it’s own kernel that can also run Linux as a process.
The naming is a little bit confusing. It’s not what we use - we use Linux with kernel patched with RT_PREEMPT patch that allows to enable full real-time preemption. To write programs that use it’s real-time capabilities it is necessary to properly control priorities and threading. You can find a good explanation of what’s going on and real-time “hello world” example here:
https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO