GTK C“找不到信号处理程序”。你用-rdynamic编译了吗?

时间:2017-07-10 13:40:56

标签: c gtk glade

所以我尝试关闭一个窗口(不破坏主窗口)的小尝试前进了一点,但击中了另一块石头。代码编译时没有错误或警告,但是当我按下按钮触发“on_window_sidebar1_back_clicked”时,运行该程序的控制台会发出错误"Could not find signal handler 'on_window_sidebar1_back_clicked'. Did you compile with -rdynamic?

我用-rdynamic运行我的编译器,它没有帮助。

负责关闭窗口的部分代码:

void on_window_sidebar1_back_clicked() 
 {
    void
    gtk_close_window(secondWindow); //sedondWindow is defined further up. no errors related to it.
 }

my window_main.glade(警告!LONG)

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
  <requires lib="gtk+" version="3.10"/>
  <object class="GtkWindow" id="window_main">
    <property name="width_request">800</property>
    <property name="height_request">480</property>
    <property name="can_focus">False</property>
    <property name="title" translatable="yes">test</property>
    <property name="default_width">800</property>
    <property name="default_height">480</property>
    <property name="skip_taskbar_hint">True</property>
    <property name="decorated">False</property>
    <property name="deletable">False</property>
    <signal name="destroy" handler="on_window_main_destroy" swapped="no"/>
    <child>
      <object class="GtkFixed" id="fixed1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkLabel" id="lbl_test">
            <property name="width_request">100</property>
            <property name="height_request">30</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">test</property>
          </object>
          <packing>
            <property name="x">400</property>
            <property name="y">190</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="lbl_count">
            <property name="name">3</property>
            <property name="width_request">100</property>
            <property name="height_request">30</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">label</property>
          </object>
          <packing>
            <property name="x">400</property>
            <property name="y">240</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="btn_count">
            <property name="label" translatable="yes">get count</property>
            <property name="width_request">100</property>
            <property name="height_request">34</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_btn_count_clicked" swapped="no"/>
          </object>
          <packing>
            <property name="x">400</property>
            <property name="y">290</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="nonconfigured2">
            <property name="label" translatable="yes">button</property>
            <property name="width_request">100</property>
            <property name="height_request">100</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
          </object>
          <packing>
            <property name="x">700</property>
            <property name="y">200</property>
          </packing>
        </child>
        <child>
          <object class="GtkButton" id="sidebar_1">
            <property name="label" translatable="yes">  open 
window
    1</property>
            <property name="width_request">100</property>
            <property name="height_request">100</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_sidebar_1_clicked" swapped="no"/>
          </object>
          <packing>
            <property name="x">700</property>
            <property name="y">100</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
  <object class="GtkWindow" id="window_sidebar1">
    <property name="width_request">800</property>
    <property name="height_request">480</property>
    <property name="can_focus">False</property>
    <property name="resizable">False</property>
    <property name="hide_titlebar_when_maximized">True</property>
    <property name="decorated">False</property>
    <property name="deletable">False</property>
    <child>
      <object class="GtkFixed" id="fixed2">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkButton" id="window_sidebar1_back">
            <property name="label" translatable="yes">BACK</property>
            <property name="width_request">70</property>
            <property name="height_request">30</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <signal name="clicked" handler="on_window_sidebar1_back_clicked" swapped="no"/>
          </object>
          <packing>
            <property name="x">50</property>
            <property name="y">400</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>

任何可能导致这种情况的想法?让我们专注于这个主题。

编辑:继承我的makefile

# change application name here (executable output name)
TARGET=ETE

# compiler
CC=/usr/bin/arm-linux-gnueabihf-gcc
# debug
DEBUG=-g
# optimisation
OPT=-O0
# warnings
WARN=-Wall

PTHREAD=-pthread

CCFLAGS=$(DEBUG) $(OPT) $(WARN) $(PTHREAD) -pipe

GTKLIB=`pkg-config --cflags --libs gtk+-3.0`  -rdynamic

# linker
LD=gcc
LDFLAGS=$(PTHREAD) $(GTKLIB) -export-dynamic

OBJS=   main.o

all: $(OBJS)
    $(LD) -o $(TARGET) $(OBJS) $(LDFLAGS)

main.o: src/main.c
    $(CC) -c $(CCFLAGS) src/main.c $(GTKLIB) -o main.o

clean:
    rm -f *.o $(TARGET)

1 个答案:

答案 0 :(得分:0)

我的问题是用户端的错误。我忘了在终端设备上清理构建并且在那里有一些重叠的目录。在移动存储库时,linux决定优先考虑旧存储库。问题得到解决,令人惊讶的是,代码可以运行。

编辑:

我也转而使用

var table = $('#data').DataTable();
$('#data tbody').on('click', 'td.details-control,.addsta,.mjump,.mcon,.delwf', function () {    
    if (this.className == "btn btn-danger delwf") {
    var tr = $(this).closest('tr');
    var row = table.row(tr);
            $scope.sworcode = row.data().worcode;
            $scope.slancode = row.data().lancode;
            console.log(row.data().worcode);
            $scope.$apply();
            $('#modal-del').modal('show');
            };
}

而不是

void on_sidebar1_back_clicked()
 {
    gtk_widget_destroy(GTK_WIDGET(secondWindow));
 }

并将我的信号改为更短,以避免(人类)记忆问题。