gcc未定义的引用 [英] gcc undefined reference to

查看:379
本文介绍了gcc未定义的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  gcc -c -I / usr / vt / sample ttssample.c 
gcc -L。 -lttsapi ttssample.o -o ttsample

我收到以下错误... p>

  ttssample.o:在函数`_TTSFile'中:
ttssample.c :( .text + 0x352):undefined reference to `TTSRequestFile'
ttssample.o:在函数`_TTSFileEx'中:
ttssample.c :( .text + 0x5e0):对'TTSRequestFileEx'的未定义引用
ttssample.o:在函数中_TTSBuffer ':
ttssample.c :(。text + 0x833):对'_TTSRequestBuffer'的未定义引用
ttssample.o:函数'_TTSBufferEx':
ttssample.c :( .text + 0xabd ):对'_TTSRequestBufferEx'的未定义引用
ttssample.o:在函数'_TTSBuffering_cont'中:
ttssample.c :( .text + 0xcbf):对'_TTSRequestBuffer'的未定义引用
ttssample.o :在函数`_TTSBuffering_stop'中:
ttssample.c :(。text + 0xf2d):对_TTSRequestBuffer的未定义引用
ttssample.o:函数`_TTSBuffering_SSML':
ttssample.c: (.text + 0x122b):对_TTSReq的未定义引用utsBufferSSMLEx'
ttssample.o:在函数`_TTSStatus'中:
ttssample.c :(。text + 0x157b):未定义的引用'TTSRequestStatus'
collect2:ld返回1退出状态

和TTSRequestFile位于lib头文件中,但它的前面有DllExport,我想知道的是我的错误的原因?任何帮助非常感谢。

  DllExport int TTSRequestFile(char * szServer,int nPort,char * pText,int nTextLen,char * szSaveDir ,char * szSaveFile,int nSpeakerID,int nVoiceFormat); 


解决方案

您的链接命令是错误的。应在命令末尾指定库:

 gcc ttssample.o -o ttsample -L。 -lttsapi 


I'm running..

gcc -c -I/usr/vt/sample ttssample.c
gcc -L. -lttsapi ttssample.o -o ttsample

and I'm getting the following error...

ttssample.o: In function `_TTSFile':
ttssample.c:(.text+0x352): undefined reference to `TTSRequestFile'
ttssample.o: In function `_TTSFileEx':
ttssample.c:(.text+0x5e0): undefined reference to `TTSRequestFileEx'
ttssample.o: In function `_TTSBuffer':
ttssample.c:(.text+0x833): undefined reference to `_TTSRequestBuffer'
ttssample.o: In function `_TTSBufferEx':
ttssample.c:(.text+0xabd): undefined reference to `_TTSRequestBufferEx'
ttssample.o: In function `_TTSBuffering_cont':
ttssample.c:(.text+0xcbf): undefined reference to `_TTSRequestBuffer'
ttssample.o: In function `_TTSBuffering_stop':
ttssample.c:(.text+0xf2d): undefined reference to `_TTSRequestBuffer'
ttssample.o: In function `_TTSBuffering_SSML':
ttssample.c:(.text+0x122b): undefined reference to `_TTSRequestBufferSSMLEx'   
ttssample.o: In function `_TTSStatus':
ttssample.c:(.text+0x157b): undefined reference to `TTSRequestStatus'
collect2: ld returned 1 exit status

and TTSRequestFile is in the lib header but it has DllExport on the front of it which I'm wondering is the cause of my error? Any help much appreciated.

DllExport int TTSRequestFile(char *szServer, int nPort, char *pText, int nTextLen, char *szSaveDir, char *szSaveFile, int nSpeakerID, int nVoiceFormat);

解决方案

Your link command is wrong. Libraries should be specified at the end of the command:

gcc ttssample.o -o ttsample -L. -lttsapi

这篇关于gcc未定义的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆