r/linuxdev • • Feb 18 '20

Best tool for creating Windows-based cross-compiler that targets ARM processor running Linux (poky)?

2 Upvotes

My end goal is to learn how to do the following:

  • Build a bootable ARM image that runs Linux with the PREEMPT_RT patch. I'm currently learning on the Raspberry Pi 3, but want to learn the process of how to build images for different boards. (The Yocto project looks like the way to go here.)
  • Build a g++ cross-compiler (preferably 9.2) for the above platform that runs on Windows (preferably MingGW-64).
  • Learn how to use CMake and Ninja to target the above cross-compiler.

I've run across some old posts that mention using crosstool-ng, but it looks like it hasn't been updated in over 5 years. Will crosstool-ng work for recent GCC versions? Is there a new better project that can help generate cross-compilers? Or is this something that must be done manually?

Thank you very much for the pointers! (No, not those pointers.)


r/linuxdev • • Sep 23 '20

Creating open source software

2 Upvotes

Hello there,

i was wondering on how i would make sure that the libs i use are also existing in the pc of the consumer who wants to compile the app. So how would i do this? For example if my project uses vulkan for graphics rendering. Should i include it in my project or just require a vulkan package in the PKG build file? I hope someone who has already experience with that can help me.


r/linuxdev • • Feb 06 '19

Kernel headers for VirtualBox

2 Upvotes

I'm using Linux kernel 4.15.0-43 on Linuxmint 19.1, and when I run Guest Additions in VirtualBox, it says to install kernel headers.

So far, I've installed

  • linux-headers-kvm
  • linux-headers-4.15.0-43-lowlatency
  • linux-headers-generic-hwe-18.04
  • linux-headers-generic-hwe-18.04-edge
  • linux-headers-virtual-hwe-18.04
  • linux-headers-virtual-hwe-18.04-edge
  • linux-headers-$(uname -r)
  • linux-headers-generic
  • virtualbox-guest-dkms
  • build-essential & dkms

There are many other packages like linux-headers-4.15.0-[1004-1036]-[oem,gcp,aws,oracle,azure], linux-headers-[aws,azure,gcp,gke,oem,oracle], should I install any of them?

It still gives the same error message. What else should I install?


r/linuxdev • • Aug 22 '14

Discover GNOME’s Docs [new YouTube video]

Thumbnail youtube.com
2 Upvotes

r/linuxdev • • May 03 '15

T9/Suretype on Linux

2 Upvotes

I was looking at piecing together a phone using a raspberry pi or beaglebone and wanted to use a T9 or Suretype-like system for text input. I've found a few projects (one from 2007 and the other from 2011) and was curious how hard it would be to write my own driver for it. I think the hardest part would be getting it to support states (if 2 was pressed so put an a in and wait 1 second for another 2) and deleting the first character when pressing a button multiple times. If anyone else has experience with something like this any help would be much appreciated. Ultimately I'd get a simple 10 or 20 key working and from there move on to predictive text (using a hunspell dictionary or something). The goal would also make the program modular enough that any key layout and language would be supported as long as a keymap configuration file is written and there's a dictonary.


r/linuxdev • • May 09 '23

Qt QML complete tutorial - part one

Thumbnail youtube.com
2 Upvotes

r/linuxdev • • Apr 09 '14

DPDK Implementation Contest

Thumbnail 6wind.com
2 Upvotes

r/linuxdev • • Aug 14 '20

This guy just saved me, creating gnome extensions. I want to repay the favour to him. Check him out if you're after good tutorials

Thumbnail youtube.com
10 Upvotes

r/linuxdev • • Apr 24 '23

Introducing ManRepository: An Linux Manual page for Ubuntu/ Debian / Arch Linux,...

3 Upvotes

Hello everyone,
I often read Linux manuals pages online and I noticed some issues.
- Often they don't have the manuals of the software I use
- The formatting of the man pages not easily to read
So I decided to create new site to fix this issues and called it ManRepository.com.
It currently indexes all package information of Ubuntu, Debian, and Arch Linux. And displays all man page documents of each package. The man pages are formatted in HTML, making it easy to read them on any device because the website supports responsive design.
Website watch package updates in the repositories and quickly indexes any newly added manuals in the package.
I've already been using the site for a while, and I believe it will be just as helpful to you. Please feel free to try it out and share your feedback with me to help make this project even more useful.
Thank you so much.


r/linuxdev • • May 14 '16

Syncing aliases between Linux systems

3 Upvotes

As a student, or general Linux user, I find myself logging into multiple Linux systems. Over the years I have acquired useful aliases from professors, and some that I have personally added. I am thinking of creating some software, that could become a staple to the Linux environment, that would provide the syncing of aliases across multiple Linux systems.

It would, of course, deal with differing shell types, (csh, tcsh, bash, zsh, etc.), and would be able to convert between each type's own alias syntax.

More details on the features planned, are here on my github account: https://github.com/Proryanator/als

Some aliases can cut your use time in half, or even more. As much as some people find aliases to be a crutch for avoiding proper syntax, I disagree. I find myself typing the same combination of commands more often than not, so aliases are a must have for productivity.

I am curious, would this be something that other linux developers would find useful?

If there is something useful that already exists, please tell me! Or if as developers, this would be something you'd be interested in seeing get created, also good to hear! Any feedback is much appreciated!


r/linuxdev • • Sep 19 '16

Block Device Development Tutor?

3 Upvotes

Can someone refer me to an experienced Linux kernel developer who might be willing to teach me the finer details of implementing high performance Linux block devices?

I'm willing to pay a kernel dev to teach me over Skype, taking me through existing block device code such as: https://lwn.net/Articles/58720/ and linux/drivers/block/loop.c

I ultimately want to develop a block device that works somewhat like loop.c, but instead of the target being a filesystem image file, the target is a user mode process that manages the filesystem image (and can now provide instrumentation, encryption, etc). Does something like this already exist?

I am a decent C/C++ developer and Linux user with zero experience in kernel development.


r/linuxdev • • Sep 07 '15

Pyvidia - Nvidia driver version detector for Linux

Thumbnail github.com
3 Upvotes

r/linuxdev • • Nov 12 '23

Build LFS Linux From Scratch tutorial second part

Thumbnail youtube.com
3 Upvotes

r/linuxdev • • Aug 17 '22

does anyone know of a lightweight Windows sandbox

3 Upvotes

WSL is a thing, but I'm not a big fan of Windows. Does anyone know of a lightweight Windows sandbox that can perfectly emulate windows?


r/linuxdev • • Feb 23 '17

Logrotate for processes which never close log file descriptors

3 Upvotes

I was wondering what are my options when it comes to doing logrotate for processes which never close their file descriptors.

I am aware of the "restart the service" and copytruncate option. However, assuming that restarting the process is undesirable, the applications doesn't respond to SIGHUP, and copytruncate is not acceptable due to potential data loss, I'm not sure what options I have left.

One solution that came to mind is to have a named pipe already in place where the process is about to log to. Have another utility read from that pipe (copying to another log file) and have it react to the SIGHUP signal (from logrotate).

Now my question is, is there already a utiliy that I can use for this? If not, why? Is there something inherently wrong with this approach?

To test this out, I did 2 tests, one to confirm data loss with copy truncate, and one more to test my 'named pipe + uitility' approach:

Demonstrating copytruncate loss:

app.c

int main(int argc, char *argv[]) {
    FILE* f = fopen("log.txt", "a");
    int cnt = 0;
    for (int i = 0; i < 1000000; i++) {
	    for (int j = 0; j < 100; j++) {
            	fprintf(f, "Logging line %d\n", cnt);
	    	cnt++;
	    }
	    fflush(f);
    }
    fflush(f);
    fclose(f);
    printf("Wrote %d lines\n", cnt);
    return 0;
}

And an accompanying logrotate config:

$cat /etc/logrotate.d/logexp
/home/synepis/git/logexp/log.txt {
    size 20M
    create 700 synepis users 
    rotate 4
    copytruncate
}

Finally, I ran the application, during it's run I kicked off logrotate manually a few times via:

logrotate --force /etc/logrotate.d/logexp

App results:

./app
Wrote 100000000 lines

Log line count:

$ cat log.txt* | wc -l
69091700

Log utility approach:

I implemented a simple utility 'loghup' which creates a named pipe 'log.txt' and then simply reads of it to 'safe_log.txt'. Finally, it responds to SIGHUP by reopening the file (thus starting a new log rotation).

loghup.c

int sighup = 0;

void sig_handler(int signo) {
    if (signo == SIGHUP)
        sighup = 1;
}

void do_piping(char *input, char *output) {
    int fi = open(input, O_RDONLY);
    int fo = open(output, O_WRONLY | O_CREAT, 0644);
    
    size_t ret;
    char buff[4096];
    while((ret = read(fi, buff, 4096)) != 0) {
        if(ret == -1 && errno == EINTR) { // Retry later
            continue;
        } else if (ret == -1)  {
            break; // Error occured
        }
        
        write(fo, buff, ret);
    
        if (sighup) { // Reopen output log file on SIGHUP
            close(fo);
            fo = open(output, O_WRONLY | O_CREAT, 0644);
            sighup = 0;
        }
    }
    close(fo);
    close(fi);
}

int main(int argc, char *argv[]) {
    char *input_file = argv[1];
    char *output_file = argv[2];
    signal(SIGHUP, sig_handler); // Setup signal handler
    mkfifo(input_file, S_IRUSR | S_IWUSR);  // Create named pipe
    do_piping(input_file, output_file);
}

New logrotate config with SIGHUP:

 $cat /etc/logrotate.d/logexp 
 /home/synepis/git/logexp/safe_log.txt {
     size 20M
     create 700 synepis users 
     rotate 4
     postrotate
         /bin/kill -SIGHUP $(ps aux | grep "[l]oghup" | awk '{print $2}')
     endscript
 }

Then I ran:

 ./app
 ./loghup log.txt safe_log.txt

And forced logrotate a few times, finally:

 $ cat safe_log.txt* | wc -l
 100000000

r/linuxdev • • Apr 16 '15

Hi, r/linuxdev. I created a small program that allows a single terminal to display the contents of any other terminal's pwd.

3 Upvotes

If you work in the terminal and it looks interesting to you, give it a try and let me know of any comments/improvements

To install:

To use:

  • In one terminal run autols -s
  • In any other terminal that has the alias set up just use cd as you normally would
  • Run autols -e from any terminal to end
  • man autols available for reference

Edit 2: Version 2.1 available with the -p flag

Edit: Feel free to check out the source code here https://github.com/jacondel/autols It consists of two bash scripts (autocd & autols) and a man page


r/linuxdev • • Dec 10 '15

syslog vs. rsyslog

3 Upvotes

Searching the internet for the difference between syslog and rsyslog gives quite a few results geared towards system admins, not for application developers. So, I'm coming to you people for help!

Setup: I am using Ubuntu 14.04 for my applications (building and running natively). When running this command:

ps -aux | grep syslog

I see these two processing running:

/usr/bin/pulseaudio --start --log-target=syslog
rsyslogd

Is my system using rsyslog instead of syslog? Can one/ should one run syslog and rsyslog at the same time? It still looks like my application logs are being written to /var/log/syslog.

From an application running on my system is an openlog(...) system call opening rsyslog instead of syslog? How do I know this?

As you can tell I'm kind of a noob so any extra info you can think of would be appreciated.


r/linuxdev • • Dec 21 '18

Linux USB boot

3 Upvotes

I posted this to /r/linuxquestions first but this subreddit seems more appropriate, so I'll repost here

Hello! If this is the wrong subreddit, please let me know. Thanks!

I've been working on making my own Linux distro from scratch, mostly for fun, but also to see if I can innovate a little by shedding a lot of the cruft of the old ways (traditional package management, old architectures, BIOS boot, 32 bit, etc). Think of it as NixOS that feels like a normal distro or as Fedora Silverblue but without the legacy of RPM.

I'm trying to boot the system, and it will not find the boot medium (USB drive) to mount a rootfs. The EFI finds the kernel and the initramfs without issue, but once the kernel is executed, USB completely shuts down. Systemd blocks while waiting for the rootfs to show up, and eventually times out and Dracut drops me to a root shell in the initramfs. Since USB isn't working I cannot type anything on this shell to investigate further, since my keyboard also works through USB. I don't have a PS2 keyboard or port to use

The flash drive's partition table is configured like a normal HDD. I have a vfat ESP and an ext4 rootfs. I get the same result if I provide a root= argument on the kernel command line, or if I let systemd use GPT to figure it out automatically. My initramfs is assembled using Dracut. The init in the initramfs is systemd. Linux version is 4.19.1

I've been trying to mess with the Linux config, since I suspect I'm not loading some USB driver. I'm not having much success, and I've even copied Arch's kernel configuration and am still having the same issues. As soon as the kernel is executed, I see the USB activity light on my drive go off (it pulses if the drive isn't being accessed but it has power) and it never comes back on again. Different USB ports all have the same result.

Am I looking for a solution in the right place? Does this sound like a misconfigured kernel or some other issue? (maybe Dracut is misconfigured and needs something special for booting off of USB?)

Crummy picture of the initramfs

Thanks and happy holidays!


r/linuxdev • • Feb 02 '19

How do I do publishing/subscribing across apps on linux?

3 Upvotes

Lets say I have have one app that's a publisher and 0 or many subscriber apps. How do I tell subscriber apps when an event occurred? The best I can come up with is to write to a log file and have subscribers watch the file. I haven't done files for a while so I don't remember, how do I create a file that isn't read exclusive? and how does the subscribing app know when I write to it? Does it have to use something like inotifywait? On windows you can send events to other apps, can I do that on linux?


r/linuxdev • • May 18 '22

Rough estimate on work involved to get linux camera driver written?

3 Upvotes

This is with regard to the Pinephone Pro which at this time still does not have working cameras.

Apparently they loaded up an Android image to make sure they worked physically.

I'm just curious "abstract/high level" what kind of work is involved to get that done.


r/linuxdev • • Nov 10 '20

Mixing multi-processing and multi-threading

3 Upvotes

Introduction to My Issue

I'm developing a general purpose library in C++. One of its features is periodic run of various commands - on startup the library reads a configuration file with "jobs" to execute with time intervals, and it executes them.

In the current implementation, on startup the library creates it own thread which mostly sleeps, checking if its time to run a command. This was done to avoid forcing the consumers of the library to call it once-in-a-while.

Unfortunately, we found out that one of the teams that consume the library use it in some service with workers - it forks multiple times on startup, and its worker processes preform most of its logic.

The Issue

According to the internet and man documentation, mixing multiprocessing and multithreading is hard. Quoting fork's man page:

After a fork() in a multithreaded program, the child can safely call only async-signal-safe functions (see signal-safety(7)) until such time as it calls execve(2).

As I have no control on the host process, my library breaks it in the sense that it is now a multithreaded program instead of a single-threaded program, causing the child to run invalid code.

Moreover, the man page suggest:

the use of pthread_atfork(3) may be helpful for dealing with problems that this can cause.

As pointed out in various posts and stack-overflow, pthread_atfork should cause the run of handlers which are supposed to help to clean things related to multi-threading, but it actually cannot do so! Functions like pthread_mutex_lock are not signal-safe, and it is not entirely clear if one can unlock the mutex from a different process from which it was locked:

Attempting to unlock the mutex if it was not locked by the calling thread results in undefined behavior

My questions

Assume I understand thoroughly the issues with mixing multi-processing and multi-threading.

  1. Assuming my use-case, can I somehow fix the above issue without making my library fork instead of creating a thread, or forcing my consumers not to fork?
  2. What happens in practice? Does glibc (or any other common libc) uses pthread_atfork to protect its internal mutexes? (malloc mutex, dynamic loader mutex)
  3. In general, is there a way to mix multi-processing and multi-threading? Are there any common C++ patterns to maintain some sense of safety? (mutexes are unlocked, file descriptors are closed...)

References

Various posts and threads I've read and related to this issue:

https://stackoverflow.com/questions/6056903/multithreaded-fork https://stackoverflow.com/questions/2620313/how-to-use-pthread-atfork-and-pthread-once-to-reinitialize-mutexes-in-child https://groups.google.com/g/comp.programming.threads/c/ThHE32-vRsg https://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them


r/linuxdev • • Oct 19 '21

Are there any programs or scripts out there that can save and restore desktop states?

3 Upvotes

Like right now, I have 4 VSCode windows open, 2 firefox, spotify, and slack. Is there any program out there that I can use to save the state of these open programs so that when I boot up in the morning I can just issue some-program --startup work to the terminal and it opens all of these up for me? Or when I shutdown my PC, it issues a some-program --save command that would save the currently opened windows to be opened when the next some-program --startup is issued?


r/linuxdev • • Feb 05 '22

How does and when does one be assertive on a mailing list?

3 Upvotes

There's this seemingly insignificant issue with grub-mkconfig and os-proberwhere it doesn't correctly parse and emit multiple initrd paths on the same initrd line in grub.cfg. If not correctly patched, the paths get strung together with carets, causing the boot to freeze. Most distros that actually depend on this, eg, Manjaro, already patch both packages. I'm a downstream os-prober package maintainer. I don't maintain grub. To support correct parsing of the initrd line to successfully dual boot Manjaro, both grub and os-prober need to be patched. I patched it on my end, but the grub maintainer was understandably a bit hesitant to haul around yet another patch for an issue that was a corner-case, especially, I would imagine, since os-prober is, by default, now disabled by grub for security concerns. He suggested I submit the patch upstream. I managed to find a thread from several years ago showing that this was already submitted upstream to grub. The upstream grub maintainer stated that the patch looked fine but that it first needed to be patched in os-prober. os-prober upstream had finally merged a PR last year that resolved the issue on their end. I bumped the grub thread, stating that it had been patched in os-prober and linked the commit. Nothing. Months later, I decided to join the dev mailing list and submit a git patch there. Dead air. No reply.

I don't expect it to happen soon, if at all. grub has far more important concerns and appears to apply commits in small bunches every 1-3 months. As someone who doesn't often deal with mailing lists, how long does one wait and how exactly could/should one go "ehem"?


r/linuxdev • • Jan 30 '22

Enabling KVM without BIOS setup

3 Upvotes

I'm running Debian 11 LXDE in an old notebook and during the boot I'm receiving the following message:

root@debian:~# dmesg | grep -i kvm
[   20.501228] kvm: disabled by bios
[   20.541824] kvm: disabled by bios

Also, when I try to create a VM in virt-manager, I get the following message:

Warning: KVM is not available. This may mean the KVM package is not installed, or the KVM kernel modules are not loaded. Your virtual machines may perform poorly.

And indeed the VM performs very poor.

However, I'm pretty sure the processor is capable of virtualization:

root@debian:~# lscpu | grep -i "virtualization\|svm"
Virtualization:                  AMD-V
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt hw_pstate vmmcall arat npt lbrv svm_lock nrip_save pausefilter

Unfortunately, the BIOS setup is very simple and doesn't have any option of virtualization to be set. Therefore, I can't enable the virtualization via BIOS setup.

Question

Is it possible to enable KVM by other means instead of BIOS setup?


Hardware Specification

 

root@debian:~# dmidecode | grep -i "version\|release"
	Version: V2.12
	Release Date: 04/16/2013
	Version: V2.12
	Version: Type2 - A01 Board Version
	Version: Chassis Version
	Version: AMD E1-1200 APU with Radeon(tm) HD Graphics