12-15-2025, 11:53 AM (This post was last modified: 12-15-2025, 11:55 AM by Petr.)
I will add SO files (Linux dynamic libraries) to this thread.
A question to the developers first. In the following program, I spent an hour searching for the reason why the IDE (4.2.0) in Linux (virtualized Ubuntu in Windows 10) does not see the SO file. How is it possible that the library name must be different from the actual library name on disk? Why? I don't understand!
I will gradually add more things here, but please be patient.
Zip file contains BAS code, C code for SO library and SO library.
12-15-2025, 12:22 PM (This post was last modified: 12-15-2025, 12:29 PM by SpriggsySpriggs.)
What's the reason for using a dynamic library rather than compiling with a header into the code?
It works just fine by removing the EXPORT tags on the file, making it a .h header, adding the flags to the compiler in QB64, and then building.
Code: (Select All)
'Declare Dynamic Library "listpick"
' Function PickFromListUTF8& (title As String, prompt As String, items As String, ByVal startIndex As Long)
' Function PickFromListUTF8_Text& (title As String, prompt As String, items As String, ByVal startIndex As Long, outText As String, ByVal outBytes As Long)
'End Declare
Declare CustomType Library "ListPick_GTK"
Function PickFromListUTF8& (title As String, prompt As String, items As String, ByVal startIndex As Long)
Function PickFromListUTF8_Text& (title As String, prompt As String, items As String, ByVal startIndex As Long, outText As String, ByVal outBytes As Long)
End Declare
' --- use ---
title$ = "Select item" + Chr$(0)
prompt$ = "Write for filter, Enter=OK, Esc=Cancel" + Chr$(0)
item:
Data "Alpha","Beta","Gamma","Delta","Etha","Theta","Omikron","Mi","Psi","Kocici","Kachni","Rozum","Zelenej","Linux","To je ale dilo"
Restore item
For f = 1 To 15
Read i$
items$ = items$ + i$ + Chr$(10)
Next f
items$ = items$ + Chr$(0)
out$ = Space$(2048) ' buffer, in which C write text
idx& = PickFromListUTF8_Text&(title$, prompt$, items$, 1, out$, Len(out$))
out$ = ZTrim$(out$)
Print "idx="; idx&, " text="; out$
Function ZTrim$ (s$)
Dim p As Long
p = InStr(s$, Chr$(0))
If p > 0 Then ZTrim$ = Left$(s$, p - 1) Else ZTrim$ = s$
End Function
static gboolean row_is_effectively_visible(GtkWidget *w) {
// u GtkListBox filtrování typicky schovává řádky přes child_visible, ne přes visible
return gtk_widget_get_child_visible(w);
}
static gboolean contains_nocase_utf8(const char *hay, const char *needle) {
if (!needle || !*needle) return TRUE;
if (!hay) return FALSE;
// při OK ještě jednou dorovnej selection podle filtru (klik na OK myší by jinak mohl vrátit starou selection)
if (resp == GTK_RESPONSE_OK) {
gtk_list_box_invalidate_filter(GTK_LIST_BOX(p.list));
while (gtk_events_pending()) gtk_main_iteration();
ensure_selection(&p);
}
int result = -1;
if (resp == GTK_RESPONSE_OK) {
GtkListBoxRow *sel = gtk_list_box_get_selected_row(GTK_LIST_BOX(p.list));
if (sel && row_is_effectively_visible(GTK_WIDGET(sel))) {
result = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sel), "orig"));
GtkWidget *child = gtk_bin_get_child(GTK_BIN(sel));
copy_out(out, outBytes, gtk_label_get_text(GTK_LABEL(child)));
} else {
copy_out(out, outBytes, "");
result = -1;
}
} else {
copy_out(out, outBytes, "");
result = -1;
}
gtk_widget_destroy(p.dialog);
while (gtk_events_pending()) gtk_main_iteration();
(12-15-2025, 11:53 AM)Petr Wrote: How is it possible that the library name must be different from the actual library name on disk? Why? I don't understand!
There is an extremely strong Linux (and other Unix?) convention that the dynamic library "foo" can be found on disk in the file "libfoo.so" and QB64 follows suit here.
You're not wrong, it's just as you write. What surprises me is that the compiler reports a missing GTK. But according to Linux, GTK is installed there. It lists the version, it's installed correctly. But I doesn't have deep knowledge about Linux, so I can only guess why it doesn't work for me. H files works fine for me in Windows.
12-15-2025, 06:56 PM (This post was last modified: 12-15-2025, 06:59 PM by Petr.)
Input Box for Linux. This time use H file.
Code: (Select All)
Declare CustomType Library "./IbLNX"
Function InputBoxUTF8_Text& (title As String, prompt As String, def As String, outText As String, ByVal outBytes As Long)
End Declare
12-15-2025, 08:21 PM (This post was last modified: 12-15-2025, 08:23 PM by SpriggsySpriggs.)
It's a library. With requirements. Once it is embedded in a program, that's it. You wouldn't have to make sure you are deploying your program with another file. You just have a comment in the library or a readme file telling them how to use it. That's it. "Add these flags to QB64 to build with this header". If they have a problem with that, then they're incredibly lazy. Besides, they'd still need the packages installed to use it anyways, regardless if it is a header or SO.