Labels

Android (1) Apache (1) bash (2) boost (2) C (37) C++ (5) cheatsheet (2) CLion (6) css (3) Debian (34) DL (17) dns (1) Docker (3) Dreamweaver (2) Eclipse (3) fail2ban (5) git (6) GitHub (5) Hacking (4) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (33) javascript (3) Linux (182) Mac (21) Machine Learning (1) mySQL (53) Netbeans (6) Networking (1) Nexus (1) OpenVMS (6) Oracle (4) Pandas (3) php (17) Postgresql (8) Python (9) raid (1) RedHat (15) Samba (2) Slackware (52) SQL (14) ssh (1) svn (1) tar (1) ThinkPad (1) Virtualbox (4) Visual Basic (2) Visual Studio (1) Windows (7) wire (1)
Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

Friday, 24 April 2026

Target windows XP from Mac using Netbeans and Docker

I had tried building C/C++ applications for Windows XP using my Mac and mingw-w64 installed using Home-brew but it just didnt work out. This mostly resulted in the following when trying to run the executable on Windows XP;


What I finally discovered and use is, setting up a Docker image with the appropriate XP-compatible toolchain, ie. a MinGW that targets MSVCRT, not UCRT.

Friday, 9 December 2022

How to remove a char from a C char array by index.

I use the following to remove a char from a C char array by index.

In this instance, I search for the first char and if it's a 0 then remove it.

Wednesday, 6 January 2021

Problem building meslink

I had trouble building mesllink using Netbeans but note that it did build correctly from the original source on the box, from the command line by running make.

This is similar to a problem I had with mesdb detailed here. (worth reading first).

Sunday, 20 December 2020

Problem building mesdb

I had trouble building mesdb using Netbeans but note that it did build correctly from the original source on the box, from the command line by running make.

Sunday, 1 November 2020

mysql++.h and libmysql++-dev missing in Debain 10

mysql++ 

is missing in Debian 10 and despite several attempts to install it, I haven't yet been able to, so...

to install it under Debian Bullseye, do;

apt install libmysql++-dev

Bullseye can be found here: https://www.debian.org/devel/debian-installer/

See also here: https://packages.debian.org/search?keywords=libmysql%2B%2B-dev&searchon=names&suite=all&section=all


Thursday, 22 October 2020

Sunday, 20 September 2020

Saturday, 5 September 2020

Run a C program as a daemon in Linux

Tested on Slackware 14.2 (to be tested on Debian)

Mostly from here

The complete working skeleton code can be found here 

When launched, this will live for 20 seconds and then terminate, logging startup and exit messages to /var/log/messages not syslog as expected on Slackware 14.2 but verified to write to /var/log/syslog on Debian 10.5

This can be pulled from: https://github.com/plisken1/daemon_template.git

Writing to the message log in Linux with C

 The following is an example of writing to the message log in Linux with C

from here, maybe here and also here if you are feeling brave.

#include <syslog.h>

#include <stdio.h>


int main()

{


setlogmask (LOG_UPTO (LOG_NOTICE));


openlog ("myprogramlog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);


for (int x=0;x<10;x++)

   {

   syslog (LOG_NOTICE, "Program started, count = %d",x);

   syslog (LOG_INFO, "A tree falls in a forest");

   }


closelog ();


return 0;


}

Linux Daemon Writing HOWTO

 The following is a copy of the document from here

Linux Daemon Writing HOWTO

Devin Watson

v1.0, May 2004
This document shows how to write a daemon in Linux using GCC. Knowledge of Linux and a familiarity with C are necessary to use this document. This HOWTO is Copyright by Devin Watson, under the terms of the BSD License.

Friday, 4 September 2020

Build C++ app in CLion for Linux (including a MySQL application)

How to build a C++ application, using MySQL and deploy on Linux.

In this case, we are using Debian 10 (also works on Slackware 14.2)

We are building an application (example can be found here, albeit slightly modified but importantly includes mysql.h). Also on GitHub here 

MySQL install on Debian & solution to mysql-config not found.

To install mysql server on Debian

apt-get install mariadb-server

To start, run;

service mysql start

I also found mysql_config not to be found on Debian 10

likely due to the development stuff not being installed as I could also not find /usr/include/mysql

so, installing and resolving is as follows;

sudo apt-get install libmariadb-dev-compat

also worthwhile maybe;

alp-get install libmysqlcppconn-dev

apt-get install libmysql++