gpt4 book ai didi

c - GTK C "Could not find signal handler ''。你是用-rdynamic编译的吗? ”

转载 作者:行者123 更新时间:2023-11-30 16:43:43 25 4
gpt4 key购买 nike

因此,我试图再次关闭一个窗口(而不是破坏主窗口)的小尝试进行了一点,但又撞到了另一 block 石头。代码编译时没有错误或警告,但是当我按下触发“on_window_sidebar1_back_clicked”的按钮时,运行所述程序的控制台会发出错误“无法找到信号处理程序'on_window_sidebar1_back_clicked'。您是否使用-rdynamic进行编译?.

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

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

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

我的window_main.glade(警告!很长)

<?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)

最佳答案

我的问题是用户端出现错误。我忘记清理终端设备上的构建,并且其中有一些重叠的目录。当移动存储库时,Linux 决定优先考虑旧的存储库。问题解决了,令人惊讶的是,代码可以工作。

编辑:

我也改用了

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

而不是

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

并将我的信号更改为短一点以避免(人类)内存问题。

关于c - GTK C "Could not find signal handler ''。你是用-rdynamic编译的吗? ”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45013607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com