Tuesday, January 11, 2022

How to distribute a GTK+ application on Windows?

Ref: https://newbedev.com/how-to-distribute-a-gtk-application-on-windows

You have some hints on the Windows page of the GTK website. This is the section named Building and distributing your application. It features a blog post about distributing a GTK application on Windows.

The solution proposed there is to create a MSYS2 package for your application, and then install it and all its dependencies (GTK among them) in a specific directory, so that you can redistribute the whole package.

2020-12-09 EDIT:

Reading the other answers, I want to add that this method not only gets the dependencies for shared objects and binaries right, but that should also work with other kinds of ressources (images, help files, etc.) that are in the required packages, as well as shared objects loaded at runtime with dlopen-based functions. This is something you can't get with just calling ldd to find the dependencies.


It turns out that running ldd mygtkapp.exe (with the ldd provided with MinGW) gave me a listing of all the dlls required to let it run. To get only the dlls which were gtk dependencies (and not e.g. Win32 dlls) I used the following command: ldd mygtkapp.exe | sed -n 's/\([^ ]*\) => \/mingw.*/\1/p' | sort. My program used the Haskell bindings, so the dependencies might be a bit different, but this is what I got:

libatk-1.0-0.dll
libbz2-1.dll
libcairo-2.dll
libcairo-gobject-2.dll
libepoxy-0.dll
libexpat-1.dll
libffi-6.dll
libfontconfig-1.dll
libfreetype-6.dll
libgcc_s_seh-1.dll
libgdk_pixbuf-2.0-0.dll
libgdk-3-0.dll
libgio-2.0-0.dll
libglib-2.0-0.dll
libgmodule-2.0-0.dll
libgobject-2.0-0.dll
libgraphite2.dll
libgthread-2.0-0.dll
libgtk-3-0.dll
libharfbuzz-0.dll
libiconv-2.dll
libintl-8.dll
libpango-1.0-0.dll
libpangocairo-1.0-0.dll
libpangoft2-1.0-0.dll
libpangowin32-1.0-0.dll
libpcre-1.dll
libpixman-1-0.dll
libpixman-1-0.dll
libpng16-16.dll
libstdc++-6.dll
libwinpthread-1.dll
zlib1.dll

Note also that there are a couple of other things you need to do to make a completely standalone application, particularly if you're using stock icons; for more details on this, see https://stackoverflow.com/a/34673860/7345298. Note however that I needed to copy the 16x16 directory instead of the scalable directory.

EDIT: I've actually found the following command to be very useful as well: ldd mygtkapp.exe | grep '\/mingw.*\.dll' -o | xargs -I{} cp "{}" .. This command actually copies the dlls to the current directory obviating the need to laboriously do it yourself.


The following procedure can be used to obtain the necessary DLLs:

  1. Download Listdlls
  2. Leave your application running
  3. Open the PowerShell window where Listdlls.exe is located
  4. Use the command ./Listdlls.exe application_name.exe
  5. Copy all listed paths to a text file
  6. Delete all lines that contain "C:\WINDOWS*" in your text file
  7. Leave only the lines that contain "C:\msys64*...*.dll" in your text file
  8. Open Msys2 Shell
  9. Use $ cp "paste_all_paths_from_dlls" "destination_path"

Cautions before using the $ cp command. In your text file, change "\" to "/" in the paths and remove line breaks.

 



Saturday, January 8, 2022

Camel XML to Java DSL convert utility


 https://github.com/jorgecastro05/camel-xml2dsl

Installing the script:

pip install camel_xml2dsl-0.0.x-py3-none-any.whl

Where x belongs to release version

Running the script

xml2dsl --xml xml_context_file.xml

Building the project (for developers)

Install dependencies

python3 -m pip install --upgrade build
python -m build

build and install

python -m build && pip install dist/camel_xml2dsl-0.0.1-py3-none-any.whl --force-reinstall



Thursday, December 30, 2021

Mingw-w64: How to fix “File too big/too many sections”


Ref: https://digitalkarabela.com/mingw-w64-how-to-fix-file-too-big-too-many-sections/

When you compile large source files that use templates intensively, you may receive the “File too big/too many sections” error. For the Visual Studio compiler you can simply use the /bigobj flag. The equivalent in mingw-w64 is the -mbig-obj flag. However, this is not a compiler flag but the GNU assembler and it should be passed to it.

You can set the assembler’s flags by using -Wa,<assembler_flags_comma_separated> in compiler for example:

g++ -g - Og -std=c++11 -m64 -Wa,-mbig-obj main.cpp

The syntax may seem strange but it is correct. Attempting to add the -mbig-obj flag directly to compiler will result in an error:

g++: error: unrecognized command line option ‘-mbig-obj’

Supported versions:

In my experience, you need version 2.30 of GNU binutils (in version 2.25 linking can hang).


Tuesday, December 21, 2021

How to do the port forwarding from one ip to another ip in same network?

 

Ref: https://serverfault.com/questions/586486/how-to-do-the-port-forwarding-from-one-ip-to-another-ip-in-same-network

These rules should work, assuming that iptables is running on server 192.168.12.87 :

#!/bin/sh

echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -F
iptables -t nat -F
iptables -X

iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.12.77:80
iptables -t nat -A POSTROUTING -p tcp -d 192.168.12.77 --dport 80 -j SNAT --to-source 192.168.12.87

You have to DNAT incoming traffic on port 80, but you will also need to SNAT the traffic back.


Alternative (and best approach IMHO) :

Depending on what your Web Server is (Apache, NGinx) you should consider an HTTP Proxy on your front-end server (192.168.12.87) :

Thursday, December 9, 2021

How to Enable Logging in Iptables on Linux

Ref:  https://tecadmin.net/enable-logging-in-iptables-on-linux/

Enabling logging on iptables is helpful for monitoring traffic coming to our server. This we can also find the number of hits done from any IP. This article will help enable logging in iptables for all packets filtered by iptables.

Enable Iptables LOG

We can simply use following command to enable logging in iptables.

iptables -A INPUT -j LOG

We can also define the source ip or range for which log will be created.

iptables -A INPUT -s 192.168.10.0/24 -j LOG

To define level of LOG generated by iptables us –log-level followed by level number.

iptables -A INPUT -s 192.168.10.0/24 -j LOG --log-level 4

We can also add some prefix in generated Logs, So it will be easy to search for logs in a huge file.

iptables -A INPUT -s 192.168.10.0/24 -j LOG --log-prefix '** SUSPECT **'

View Iptables LOG

After enabling iptables logs. check following log files to view logs generated by iptables as per your operating system.

On Ubuntu and Debian

iptables logs are generated by the kernel. So check following kernel log file.

tail -f /var/log/kern.log

On CentOS/RHEL and Fedora

cat /var/log/messages

Monday, November 29, 2021

Flutter Web and CORS problem

 


1- Go to flutter\bin\cache and remove a file named: flutter_tools.stamp

2- Go to flutter\packages\flutter_tools\lib\src\web and open the file chrome.dart.

3- Find '--disable-extensions'

4- Add '--disable-web-security'

Thursday, November 18, 2021

How to change the RHEL 8 server hostname without a system restart

 


Ref: https://www.cyberciti.biz/faq/rhel-8-change-hostname-computer-name-command/

Type the following commands:
$ sudo hostname nixcraft-rhel8
Next edit the /etc/hostname file and update hostname:
$ sudo vi /etc/hostname
Finally, edit the /etc/hosts file and update the lines that reads your old-host-name:
$ sudo vi /etc/hosts
From:
127.0.1.1 localhost
To:
127.0.1.1 nixcraft-rhel8
Save and close the file.

Install and use xorg-server on macOS via Homebrew

  The instructions to install and use xorg-server on macOS via Homebrew: Install Homebrew (if you haven't already): /bin/bash -c ...