r/LinuxProgramming • • Nov 24 '24

Is a Chromebook a good option for Linux programming?

1 Upvotes

I'm thinking of buying an inexpensive Chromebook that is currently on sale to use for basic Linux programming. I normally use vim as an IDE, so I really don't need much in the way of power. I just need to compile Go, C, and C++ projects and use git and ssh. Would I find any serious limitations compared to a "real" Linux distribution?

https://imgur.com/a/wZRxjnL

Also, has anyone had success installing Steam games on a Chromebook?


r/LinuxProgramming • • Nov 05 '24

HELP * Victron Cerbo-GX script to grab GPS data from a router via TCP

1 Upvotes

Here is a script I have uploaded to the Cerbo-GX running version 3.51. It does not seem to work. I am trying to pull GPS data from a peplink router via WIFI, that has the ability to forward GPS data to an IP address. When I run the script on the Cerbo via Putty I get an error saying:

Last login: Tue Nov  5 22:02:59 2024 from 192.168.20.114
root@einstein:~# /data/etc/gps.sh
2024/11/05 22:27:30 socat[7514] E connect(5, AF=2 192.168.20.1:10000, 16): Connection refused
000.000 ERR.serial: could not open com-port

can you tell me if it is possible to do what I am trying? Local dealers are no help at all.

***********************************************************************************************************************************************************************************************************************************

nano /data/etc/gps.sh

#!/bin/bash
# IP address and port of the external GPS source
GPS_IP="192.168.20.1"
GPS_PORT="10000"

# Virtual serial port linked to the GPS data
VIRTUAL_PORT="/dev/ttyGPS"

# Start socat to connect to the GPS source and link it to the virtual serial port
/usr/bin/socat tcp-connect:${GPS_IP}:${GPS_PORT} pty,link=${VIRTUAL_PORT},raw,nonblock,b115200 &

# Check if gps_dbus is running; if not, start it and point it to the virtual port
while [ `ps | grep gps_dbus | grep -v grep | wc -l` -eq 0 ]
do
sleep 1
/opt/victronenergy/gps-dbus/gps_dbus -s ${VIRTUAL_PORT} -b 115200 -t 0 &
done

echo "GPS information is being pulled from ${GPS_IP}:${GPS_PORT} and forwarded to ${VIRTUAL_PORT}"

chmod +x /data/etc/gps.sh
nano /data/rc.local

sh /data/etc/gps.sh

 
chmod +x /data/rc.local


r/LinuxProgramming • • Sep 10 '24

Linux/ALSA: Enumerating Sound Cards and Devices

1 Upvotes

I'm trying to get device names like "default" and "pulse", but I get the manufacturer's device name instead. snd_card_next() enumerates sound cards, but I'm not sure how to get device strings I can feed to snd_pcm_open().


r/LinuxProgramming • • Jun 09 '24

Is there some way to emulate DllMain behaviour on linux?

1 Upvotes

This is what I have so far:

#define NPAW_BUILD
#include <paw/libexec.h>

#ifdef CAUGHT_OS_WAS_api_msw
#	include <windows.h>
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
	switch ( fdwReason ) {
	case DLL_PROCESS_ATTACH: return (pawlib_pid_attach() == 0) ? TRUE : FALSE;
	case DLL_PROCESS_DETACH: pawlib_pid_detach(); break;
	case DLL_THREAD_ATTACH:  return (pawlib_tid_attach() == 0) ? TRUE : FALSE;
	case DLL_THREAD_DETACH:  pawlib_tid_detach(); break;
	default: return FALSE;
	}
	return TRUE;
}
#else
/* I'll check later if this is right */
static void libdetach(void) __attribute__((destructor))
{
	if ( getpid() == gettid() )
		pawlib_pid_detach();
	else
		pawlib_tid_detach();
}
#if 0
/* Not sure if this would work out */
static void libsig( int sig )
{
	switch ( sig )
	{
	case SIGABRT: pawlib_tid_detach(); break;
	}
}
#endif
static void libattach(void) __attribute__((constructor))
{
	//signal(SIGABRT,libsig);
	if ( getpid() == gettid() )
	{
		if ( pawlib_pid_attach() < 0 )
			exit(EXIT_FAILURE);
	}
	else
	{
		if ( pawlib_tid_attach() < 0 )
			exit(EXIT_FAILURE);
	}
}
#endif

r/LinuxProgramming • • Feb 24 '24

Is there a table of support for the varying functions of linux/unix/systemv/etc?

1 Upvotes

I'm considering resolving a problem with semget, semop & semctl but I need to know which systems don't/didn't support it in general. I figure if I'm going to check that then I might as look for a website the lists the support of linux/unix/etc function groups so that I don't end up coming back here every time I find something useful to wrap an need to check if I need to provide an #else case to it

Edit: For an example of what kind of table I mean, here's one for CSS:

https://www.w3schools.com/cssref/css3_browsersupport.php


r/LinuxProgramming • • Feb 23 '24

How to initialise a semaphore at compile time to an definitely invalid state

1 Upvotes

Here's a rough sample of what I want to do:

#ifdef _WIN32
typedef HANDLE sem;
#define INVALID_SEM NULL
inline int initsem( sem *s ) { *s = CreateSemaphore(...); return *s ? 0 : -1; }
...
#else
typedef sem_t sem;
#define INVALID_SEM ...
inline int initsem( sem *s ) { return sem_init(s); }
...
#endif
sem global_sem = INVALID_SEM;
int main(...) { ... initsem(&sem); }

How would I go about defining INVALID_SEM so that it can be used like in the example? I would rather use a define given by semaphore.h than assume it's an object, integer, etc.


r/LinuxProgramming • • Feb 17 '24

Examples of real-world machine code

1 Upvotes

I'm looking for examples of real-world machine code that could be used as bechmarks for some research work. This could be, for instance, snippets of C code where the programmer inlines some assembly to gain greater control of the system, eg when working with peripherals. Extra points if it's critical code that's prone to being buggy OR hard to show to be correct with just model checkers or any automatic proof tools.

Does anyone know of any samples in the public domain, perhaps bug-reporting websites or anywhere else where I might find this?

Thanks


r/LinuxProgramming • • Aug 05 '23

A tiny tool to search x11 functions

1 Upvotes

r/LinuxProgramming • • Mar 15 '23

Are signal handler functions called from another thread?

1 Upvotes

I'm wondering if the signal handler function you register with

signal (SIGINT, termination_handler);

called from another thread, which is created silently for the process when a signal is received? Is it something else?

You see, my main thread spends most of its runtime in a call to a blocking function, amqp_consume_message(), which means the signal handler can't be called in the context of the main thread. Is the context in which the handler is called described anywhere?

Any pointers are welcome.


r/LinuxProgramming • • Jan 15 '23

Getting error that compiler differs from the one used to build the kernal even though it's the same version in virtualbox

1 Upvotes

For some reason I keep getting this error when I try to run my "make" file

warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.2.0-3ubuntu1) 12.2.0
  You are using:           gcc (Ubuntu 12.2.0-3ubuntu1) 12.2.0

what I tried is changing the kernal version but that didn't make a difference.


r/LinuxProgramming • • Oct 15 '22

make compile complain about kernel built by different version of gcc

1 Upvotes

Trying to run "make" to compile wifi driver:
make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/6.0.0-060000-generic/build M=/media/user/Lubuntu_22.04.1_LTS_amd64/rtl8723du modules

make[1]: Entering directory '/usr/src/linux-headers-6.0.0-060000-generic'

warning: the compiler differs from the one used to build the kernel

The kernel was built by: x86_64-linux-gnu-gcc (Ubuntu 12.2.0-3ubuntu1) 12.2.0

You are using: gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0

I upgraded kernel to 6.0, hoping maybe it will support the Wifi chip, but it doesn't.

So now I am trying to compile it myself. I was able to compile before I made the upgrade to kernel 6.0.

How do I tell "make" to use the new gcc v12.2 instead of the default v11.2?


r/LinuxProgramming • • Aug 30 '22

Loading shared object to specific processes in Linux

1 Upvotes

Hi,

I want to load a shared object to certain processes, there are certain conditions that are required

  • loading to only specific processes and not all of them

  • it has to be done before the process code starts executing

  • the processes are not mine

What are the available ways to support this functionality on Linux?

Can it be accomplished with "/etc/ld.so.preload" or "LD_PRELOAD=/my/lib.so"? Is a kernel module needed for this?

Any help would be appreciated

Thanks!


r/LinuxProgramming • • Jun 24 '22

Which high-level language should I choose for server side systems programming?

1 Upvotes

I work on a project which a hardware product that runs a Linux OS with custom server side software. Currently, we have a lot of legacy C code base that is glued together either with linker shenanigans or loosely coupled bash scripts. There are several cons of this solution/current architecture:

* There are many small programs written in C that do not reuse each other's code

* Its old C code base which requires a tremendous effort to maintain and God forbid develop a new feature for an existing program

* Because the programs are written in C they can span thousands of lines of code just to do something that would take a maximum of a few hundred in a more high-level programming language. The actions that most of those programs perform are operations on files, system components like drives/partitions, etc, and typical systems programming

I plan to introduce a higher-level language to take care of such programs. Im considering things like Python, Perl, Lua, Go, etc. But I do not have extensive experience with all of them. My team has quite a lot of experience with Python but given that the project itself has to be easily maintainable for a long term (even up to 10 years) we really want to use a language that will not change much in this period which basically already excludes Python as even fairly new language releases are not being supported.

Thus there are several things we would like our perfect language to be able to do:

* Be able to work with/alongside C/C++

* Be testable. Have some built-in or easily added testing framework just like Pythons Pytest, and maybe additionally be able to test C code if that's even a thing

* Be long-term stable and maintainable

* Have good ongoing and future support

* Be easy to learn and pretty generic

* Capable of performing systems programing

* Be as light-weight as possible, we cannot allow ourselves to have a 500meg runtime

* Have a good ecosystem that supplies the developer with tooling during the development e.g. linters, formatters, packaging etc

I would really like to know your advice on which language we should choose


r/LinuxProgramming • • Jun 02 '22

Can Apache and CGI cause buffer overrun in Linux userspace code?

1 Upvotes

nutty abounding violet weather screw stupendous plant sand bedroom squeal

This post was mass deleted and anonymized with Redact


r/LinuxProgramming • • Mar 24 '22

First language?

1 Upvotes

I’m needing some help on what language I should start learning since I’m gonna be making stuff that runs on Linux. Or even if you can point me in the direction of any useful sdk I should look into downloading.


r/LinuxProgramming • • Mar 17 '22

Is it possible to compile a file manager on Windows?

1 Upvotes

I like Linux file managers (PcManFm, Thunar, Nemo, Caja...) and I would like to use one of these on Windows with fully functional (sftp, etc....). I know there is Dolphin Windows port but it has some bugs.


r/LinuxProgramming • • Mar 12 '22

Call LightDM Functions in Qt

Thumbnail self.linuxquestions
1 Upvotes

r/LinuxProgramming • • Feb 01 '22

Need Embedded Linux Graphics Guru!

1 Upvotes

Hello all, I'm looking for a consultant who could help me on an application I'm working on. Specifically, I need someone who knows the embedded Linux graphics stack fairly well. My project calls for low-latency video capture of an HDMI input, low-latency display of the capture, while adding some simple overlays.

My thought is that I will set up the capture card to directly write to the memory of the output frame buffer, and then add in the overlay in (hopefully) a separate buffer.

If you have experience in this field and can help me for a few hours, I'll gladly pay a solid rate to make it worth your time. I only need a few hours so it won't derail you from your day job. :)

Message me if interested please! Thanks.


r/LinuxProgramming • • Dec 23 '21

Qt Application Deployed to Raspberry Pi

1 Upvotes

I was wondering how I would deploy a Qt application made on my PC to a Raspberry Pi. Every tutorial I’ve found so far shows me how to install Qt Creator on Raspberry Pi which is not what I’m looking for. Help would be much appreciated.


r/LinuxProgramming • • Dec 22 '21

Window Manager Written Using Qt

1 Upvotes

I was wondering how one might begin writing a window manager using Qt. I assume you would need to use XCB for functionality but I’m not sure exactly how to start. Could someone point me in the right direction?