如何解决未定义的引用_imp __ *? [英] How do I fix undefined reference to _imp__*?
问题描述
我试图编译的东西,取决于gtkspell,这
取决于附魔,MinGW的下。我越来越喜欢错误
gtkspell / gtkspell.c:757:未定义引用'_imp__enchant_broker_init
我怀疑这是不是因为这样的事实,我试图链接
againt一个{静态,动态}当我应该链接到的库
另外一个,或者是因为只有一个下划线小鬼前
应该有两个;我得到
$ objdump的-t /d/opt/enchant-1.6.0/lib/libenchant.a | grep的enchant_broker_init
[85](秒1)(FL×00)(TY 20)(SCL 2)(NX 0)0x00002ac0 _enchant_broker_init
和
$ objdump的-t /d/opt/enchant-1.6.0/lib/libenchant.dll.a | grep的enchant_broker_init
[6](秒1)(FL 0×00)(TY 0)(SCL 2)(为nx 0)00000000 _enchant_broker_init
[7](秒3)(FL 0×00)(TY 0)(SCL 2)(为nx 0)00000000 __imp__enchant_broker_init
互联网
(http://lists.freedesktop.org/archives/gstreamer-devel/2007-January/013975.html)
表明小鬼识别码来源于
_declspec(DLL {进口,出口})
虽然附魔似乎用
__ declspec(DLL {进口,出口})
,并注释掉相关线路中enchant.h使得gtkspell.c
要求 enchant_broker_init
,而不是 _imp__enchant_broker_init
,但
并没有改变,在libenchant显示的符号。有没有一种方法
使GCC没有裂伤的名称,或者有没有人有什么想法
可能会错误/如何解决?
下面是转载我的系统上的问题,一个最小的例子:
如果我有内容的文件enchanttest1.c
的#include<&stdio.h中GT;
#包括LT&;&enchant.h GT;诠释的main()
{
#IFDEF ENCHANT_MODULE_EXPORT
的printf(\\ nEnchant找到\\ n);
#其他
的printf(\\ nEnchant没有找到\\ n);
#万一
返回0;
}
和内容的文件enchanttest2.c
的#include<&stdio.h中GT;
#包括LT&;&enchant.h GT;诠释的main()
{
EnchantBroker * B = enchant_broker_init();
#IFDEF ENCHANT_MODULE_EXPORT
的printf(\\ nEnchant找到\\ n);
#其他
的printf(\\ nEnchant没有找到\\ n);
#万一
返回0;
}
然后
GCC enchanttest1.c`pkg配置--cflags enchant`&放大器;&安培; ./a.exe
给附魔找到
,但
GCC enchanttest2.c`pkg配置--cflags enchant`&放大器;&安培; ./a.exe
给
C:\\用户\\ JASONG〜1 \\应用程序数据\\本地的\\ Temp \\ ccyDLptc.o:testenchant.c :(文字+ 0xF的):未定义的参考`_imp__enchant_broker_init
collect2:劳工处返回1退出状态
要解决我的小例子,该方法是添加 - 库
在 --cflags
; GCC找不到要链接的库。
我能够(树胶(http://dev.midnightcoding.org/projects/gummi))的修复,我是在用更复杂的code,我本来试图编译运行问题通过 LDFLAGS =$(pkg配置--cflags --libs gtkspell-2.0附魔)CFLAGS =$(pkg配置--cflags --libs gtkspell-2.0附魔)
来配置脚本;这个问题似乎已经该参数在gcc的顺序错误过去了,它找不到附魔,当它试图链接gtkspell。
I'm trying to compile something that depends on gtkspell, which
depends on enchant, under MinGW. I'm getting errors like
gtkspell/gtkspell.c:757: undefined reference to '_imp__enchant_broker_init'
I suspect this is either due to the fact that I'm trying to link
againt a {static,dynamic} library when I should be linking against the
other one, or because there's only one underscore before the imp and
there should be two; I get
$ objdump -t /d/opt/enchant-1.6.0/lib/libenchant.a | grep enchant_broker_init
[ 85](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00002ac0 _enchant_broker_init
and
$ objdump -t /d/opt/enchant-1.6.0/lib/libenchant.dll.a | grep enchant_broker_init
[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _enchant_broker_init
[ 7](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__enchant_broker_init
The internet (http://lists.freedesktop.org/archives/gstreamer-devel/2007-January/013975.html) suggests that the imp mangling comes from
_declspec(dll{import,export})
though enchant seems to use
__declspec(dll{import,export})
, and commenting out the relevant lines in enchant.h makes gtkspell.c
request enchant_broker_init
rather than _imp__enchant_broker_init
, but
doesn't change the symbols that show up in libenchant. Is there a way
to make gcc not mangle the names, or does anyone have ideas about what
might be going wrong/how to fix it?
Here's a minimal example that reproduces the problem on my system:
If I have a file enchanttest1.c with contents
#include <stdio.h>
#include <enchant.h>
int main()
{
#ifdef ENCHANT_MODULE_EXPORT
printf("\nEnchant found\n");
#else
printf("\nEnchant not found\n");
#endif
return 0;
}
and a file enchanttest2.c with contents
#include <stdio.h>
#include <enchant.h>
int main()
{
EnchantBroker *b = enchant_broker_init();
#ifdef ENCHANT_MODULE_EXPORT
printf("\nEnchant found\n");
#else
printf("\nEnchant not found\n");
#endif
return 0;
}
then
gcc enchanttest1.c `pkg-config --cflags enchant` && ./a.exe
gives Enchant found
but
gcc enchanttest2.c `pkg-config --cflags enchant` && ./a.exe
gives
C:\Users\JASONG~1\AppData\Local\Temp\ccyDLptc.o:testenchant.c:(.text+0xf): undefined reference to `_imp__enchant_broker_init'
collect2: ld returned 1 exit status
The way to fix my minimal example is to add --libs
after --cflags
; gcc couldn't find the library to link against.
I was able to fix the problem that I was running in to with the more complicated code that I was originally trying to compile (gummi (http://dev.midnightcoding.org/projects/gummi)) by passing LDFLAGS="$(pkg-config --cflags --libs gtkspell-2.0 enchant)" CFLAGS="$(pkg-config --cflags --libs gtkspell-2.0 enchant)"
to the configure script; the problem seems to have been that the arguments to gcc were passed in the wrong order, and it couldn't find enchant when it was trying to link gtkspell.
这篇关于如何解决未定义的引用_imp __ *?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!