#include <gtk/gtk.h>
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
void pop_class()
{
CURL *curl;
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_URL, "http://api.openweathermap.org/data/2.5/forecast id=2158867&appid=a4f247bfd153738d2cd1757224361972");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
int main(int argc, char *argv[])
{
GtkBuilder *builder;
GtkWidget *window;
gtk_init(&argc, &argv);
builder = gtk_builder_new_from_file("glade/window_main.glade");
window = GTK_WIDGET(gtk_builder_get_object(builder, "window_main"));
gtk_builder_connect_signals(builder, NULL);
g_object_unref(builder);
gtk_widget_show(window);
gtk_main();
pop_class();
return 0;
}
// called when window is closed
void on_window_main_destroy()
{
gtk_main_quit();
}
this compiles correctly with
g++ -c -g -O0 -Wall -pthread -pipe src/main.cpp -lcurl `pkg-config --cflags --libs gtk+-3.0` -o main.o
and then this
g++ -o temp_app main.o -pthread `pkg-config --cflags --libs gtk+-3.0`
-export-dynamic
and on running I get the following warning -
Could not find signal handler 'on_window_main_destory'. Did you compile with -rdnamic?
destory
it looks like you have a typo. – David Buckon_window_main_destory
vson_window_main_destroy
– Michi