I have written a C program to display memory-mapped video files using GStreamer and GTK windows. The intent is to build a shared library with CFFI that I can call from Python. When I try to import the library, I get a message reporting an undefined symbol.
I recreated the problem with a library containing a small program that just displays a window:
#include <gtk/gtk.h>
#include "test_cdef.h"
int main (int argc, char *argv[])
{
return test();
}
int test()
{
GtkWidget *main_window;
gtk_init (NULL, NULL);
main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(main_window), "Test");
gtk_window_set_default_size(GTK_WINDOW(main_window), 1600, 900);
gtk_widget_show_all(main_window);
g_main_loop_run (g_main_loop_new (NULL, TRUE));
return 0;
}
When I try to import the library, I get the following message:
ImportError: [library file name]: undefined symbol: gtk_window_get_type
After a lot of searching, the problems that seem closest to mine were fixed by changing compiler/linking options. I used gcc to build the program. I assume CFFI uses the same to build the library.
If these options should be changed, I would have two questions: (1) what options should be used, and (2) how are these options communicated to CFFI? I would appreciate help with either question.
My OS is Linux Mint 19.3. The other packages are GTK-3.0, python 3.6.9, python3-cffi 1.11.5-1.
Any help would be appreciated.