简体   繁体   English

使用旧版gcc编译程序

[英]Compiling a program with a legacy version of gcc

This is probably a very difficult problem to troubleshoot with the information I can practically provide, but I'm hoping someone might be able to at least point me in a possible direction. 对于我实际可以提供的信息进行故障排除可能是一个非常困难的问题,但我希望有人能够至少指出我可能的方向。

I'm trying to install HTK ( http://htk.eng.cam.ac.uk/ ), which, according to this page needs to be installed using gcc 3.4. 我正在尝试安装HTK( http://htk.eng.cam.ac.uk/ ),根据页面需要使用gcc 3.4进行安装。 Their method of implementing backwards compatibility: 他们实现向后兼容的方法:

#yum install compat-gcc-34-c++ compat-gcc-34

won't work for me as I'm running Ubuntu (On that note, I take it I can't simply install YUM and the subsequent package, since it's an entirely different distro, but if I'm wrong I'd love to hear it). 因为我正在运行Ubuntu,所以对我不起作用(在那个时候,我接受它我不能简单地安装YUM和随后的包,因为它是一个完全不同的发行版,但如果我错了我会喜欢听到)。

I instead installed two versions of gcc 3.4 - 3.4.0 and 3.4.6 using instructions from this site. 我使用网站的说明安装了两个版本的gcc 3.4 - 3.4.0和3.4.6。 I then added the lines suggested by that page to the top of the makefile (on this note, what's the difference between makefile and makefile.in? I tried adding the lines to the top of both files regardless), both for version 3.4.0 and 3.4.6, but both failed. 然后我将该页面建议的行添加到makefile的顶部(在这个注释中,makefile和makefile.in之间的区别是什么?我尝试将这些行添加到两个文件的顶部),版本3.4.0和3.4.6,但都失败了。 I also tried, on the off-chance, compiling it with my current version (4.4.1), but that also failed. 我也尝试过,在机会上,用我当前的版本(4.4.1)编译它,但也失败了。 I got the errors: 我收到了错误:

(cd HTKLib && make HTKLib.a) \
      || case "" in *k*) fail=yes;; *) exit 1;; esac;
make[1]: Entering directory `/home/charles/bin/htk-3.4/HTKLib'
gcc  -ansi -D_SVID_SOURCE -DOSS_AUDIO -D'ARCH="i686"' -Wall -Wno-switch -g -O2 -I.    -c -o HGraf.o HGraf.c
HGraf.c:73:77: error: X11/Xlib.h: No such file or directory
HGraf.c:74:23: error: X11/Xutil.h: No such file or directory
HGraf.c:75:21: error: X11/Xos.h: No such file or directory
HGraf.c:77:27: error: X11/keysymdef.h: No such file or directory
HGraf.c:87: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
HGraf.c:88: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rootW’
HGraf.c:91: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘theCmap’
HGraf.c:92: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘theGC’
HGraf.c:93: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gcs’
HGraf.c:95: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
HGraf.c:96: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘report’
HGraf.c:97: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘hints’
HGraf.c:111: error: ‘GXcopy’ undeclared here (not in a function)
HGraf.c:111: error: ‘GXor’ undeclared here (not in a function)
HGraf.c:111: error: ‘GXxor’ undeclared here (not in a function)
HGraf.c:111: error: ‘GXinvert’ undeclared here (not in a function)
HGraf.c:151: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
HGraf.c: In function ‘InstallFonts’:
HGraf.c:164: error: ‘FontInfo’ undeclared (first use in this function)
HGraf.c:164: error: (Each undeclared identifier is reported only once
HGraf.c:164: error: for each function it appears in.)
HGraf.c:164: warning: implicit declaration of function ‘XLoadQueryFont’
HGraf.c:164: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:167: error: ‘DefaultFont’ undeclared (first use in this function)
HGraf.c: At top level:
HGraf.c:176: error: expected ‘)’ before ‘*’ token
HGraf.c: In function ‘HGetEvent’:
HGraf.c:219: error: ‘XEvent’ undeclared (first use in this function)
HGraf.c:219: error: expected ‘;’ before ‘xev’
HGraf.c:223: warning: implicit declaration of function ‘XFlush’
HGraf.c:223: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:225: warning: implicit declaration of function ‘XEventsQueued’
HGraf.c:225: error: ‘QueuedAfterFlush’ undeclared (first use in this function)
HGraf.c:226: warning: implicit declaration of function ‘XNextEvent’
HGraf.c:226: error: ‘xev’ undeclared (first use in this function)
HGraf.c:228: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:230: error: ‘ButtonPress’ undeclared (first use in this function)
HGraf.c:235: error: ‘ButtonRelease’ undeclared (first use in this function)
HGraf.c:240: error: ‘MotionNotify’ undeclared (first use in this function)
HGraf.c:245: error: ‘KeyPress’ undeclared (first use in this function)
HGraf.c:249: warning: implicit declaration of function ‘DecodeKeyPress’
HGraf.c:251: error: ‘KeyRelease’ undeclared (first use in this function)
HGraf.c:257: error: ‘Expose’ undeclared (first use in this function)
HGraf.c: In function ‘HEventsPending’:
HGraf.c:281: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:281: error: ‘QueuedAfterFlush’ undeclared (first use in this function)
HGraf.c: In function ‘HMousePos’:
HGraf.c:288: error: ‘Window’ undeclared (first use in this function)
HGraf.c:288: error: expected ‘;’ before ‘root’
HGraf.c:293: warning: implicit declaration of function ‘XQueryPointer’
HGraf.c:293: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:293: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:293: error: ‘root’ undeclared (first use in this function)
HGraf.c:293: error: ‘child’ undeclared (first use in this function)
HGraf.c: In function ‘InstallColours’:
HGraf.c:311: error: ‘XColor’ undeclared (first use in this function)
HGraf.c:311: error: expected ‘;’ before ‘greyDef’
HGraf.c:317: warning: implicit declaration of function ‘XParseColor’
HGraf.c:317: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:317: error: ‘theCmap’ undeclared (first use in this function)
HGraf.c:317: error: ‘colourDef’ undeclared (first use in this function)
HGraf.c:320: warning: implicit declaration of function ‘XAllocColor’
HGraf.c:334: error: ‘whiteDef’ undeclared (first use in this function)
HGraf.c:334: warning: implicit declaration of function ‘XQueryColor’
HGraf.c:335: error: ‘blackDef’ undeclared (first use in this function)
HGraf.c:341: error: ‘greyDef’ undeclared (first use in this function)
HGraf.c: In function ‘HSetColour’:
HGraf.c:361: warning: implicit declaration of function ‘XSetForeground’
HGraf.c:361: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:361: error: ‘gcs’ undeclared (first use in this function)
HGraf.c: In function ‘HSetGrey’:
HGraf.c:370: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:370: error: ‘gcs’ undeclared (first use in this function)
HGraf.c: In function ‘HDrawLines’:
HGraf.c:388: warning: implicit declaration of function ‘XDrawLines’
HGraf.c:388: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:388: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:388: error: ‘theGC’ undeclared (first use in this function)
HGraf.c:388: error: ‘XPoint’ undeclared (first use in this function)
HGraf.c:388: error: expected expression before ‘)’ token
HGraf.c: In function ‘HDrawRectangle’:
HGraf.c:395: warning: implicit declaration of function ‘XDrawRectangle’
HGraf.c:395: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:395: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:395: error: ‘theGC’ undeclared (first use in this function)
HGraf.c: In function ‘HFillRectangle’:
HGraf.c:402: warning: implicit declaration of function ‘XFillRectangle’
HGraf.c:402: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:402: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:402: error: ‘theGC’ undeclared (first use in this function)
HGraf.c: In function ‘HDrawLine’:
HGraf.c:408: warning: implicit declaration of function ‘XDrawLine’
HGraf.c:408: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:408: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:408: error: ‘theGC’ undeclared (first use in this function)
HGraf.c: In function ‘HFillPolygon’:
HGraf.c:414: warning: implicit declaration of function ‘XFillPolygon’
HGraf.c:414: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:414: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:414: error: ‘theGC’ undeclared (first use in this function)
HGraf.c:414: error: ‘XPoint’ undeclared (first use in this function)
HGraf.c:414: error: expected expression before ‘)’ token
HGraf.c: In function ‘HDrawArc’:
HGraf.c:427: warning: implicit declaration of function ‘XDrawArc’
HGraf.c:427: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:427: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:427: error: ‘theGC’ undeclared (first use in this function)
HGraf.c: In function ‘HFillArc’:
HGraf.c:440: warning: implicit declaration of function ‘XFillArc’
HGraf.c:440: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:440: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:440: error: ‘theGC’ undeclared (first use in this function)
HGraf.c: In function ‘HPrintf’:
HGraf.c:451: warning: implicit declaration of function ‘XDrawString’
HGraf.c:451: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:451: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:451: error: ‘theGC’ undeclared (first use in this function)
HGraf.c: In function ‘HCopyArea’:
HGraf.c:457: warning: implicit declaration of function ‘XCopyArea’
HGraf.c:457: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:457: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:457: error: ‘theGC’ undeclared (first use in this function)
HGraf.c: In function ‘HPlotVector’:
HGraf.c:476: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:476: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:476: error: ‘theGC’ undeclared (first use in this function)
HGraf.c: In function ‘HSetFontSize’:
HGraf.c:490: error: ‘CurrentFont’ undeclared (first use in this function)
HGraf.c:490: error: ‘DefaultFont’ undeclared (first use in this function)
HGraf.c:499: error: ‘FontInfo’ undeclared (first use in this function)
HGraf.c:502: warning: implicit declaration of function ‘XSetFont’
HGraf.c:502: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:502: error: ‘gcs’ undeclared (first use in this function)
HGraf.c: In function ‘HSetLineWidth’:
HGraf.c:511: warning: implicit declaration of function ‘XSetLineAttributes’
HGraf.c:511: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:511: error: ‘gcs’ undeclared (first use in this function)
HGraf.c:511: error: ‘LineSolid’ undeclared (first use in this function)
HGraf.c:511: error: ‘JoinRound’ undeclared (first use in this function)
HGraf.c:511: error: ‘FillSolid’ undeclared (first use in this function)
HGraf.c: In function ‘HSetXMode’:
HGraf.c:517: error: ‘theGC’ undeclared (first use in this function)
HGraf.c:517: error: ‘gcs’ undeclared (first use in this function)
HGraf.c: In function ‘CentreX’:
HGraf.c:523: warning: implicit declaration of function ‘XTextWidth’
HGraf.c:523: error: ‘CurrentFont’ undeclared (first use in this function)
HGraf.c: In function ‘CentreY’:
HGraf.c:529: error: ‘CurrentFont’ undeclared (first use in this function)
HGraf.c: In function ‘HTextWidth’:
HGraf.c:535: error: ‘CurrentFont’ undeclared (first use in this function)
HGraf.c: In function ‘HTextHeight’:
HGraf.c:541: error: ‘CurrentFont’ undeclared (first use in this function)
HGraf.c: In function ‘HDrawImage’:
HGraf.c:550: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
HGraf.c:550: error: ‘xi’ undeclared (first use in this function)
HGraf.c:557: warning: implicit declaration of function ‘XDestroyImage’
HGraf.c:558: warning: implicit declaration of function ‘XGetImage’
HGraf.c:558: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:558: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:558: error: ‘AllPlanes’ undeclared (first use in this function)
HGraf.c:558: error: ‘XYPixmap’ undeclared (first use in this function)
HGraf.c:562: warning: implicit declaration of function ‘XPutPixel’
HGraf.c:564: warning: implicit declaration of function ‘XPutImage’
HGraf.c:564: error: ‘theGC’ undeclared (first use in this function)
HGraf.c: In function ‘HFlush’:
HGraf.c:570: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c: In function ‘InitGCs’:
HGraf.c:780: error: ‘XGCValues’ undeclared (first use in this function)
HGraf.c:780: error: expected ‘;’ before ‘values’
HGraf.c:783: error: ‘GCLineWidth’ undeclared (first use in this function)
HGraf.c:783: error: ‘GCFunction’ undeclared (first use in this function)
HGraf.c:783: error: ‘GCForeground’ undeclared (first use in this function)
HGraf.c:785: error: ‘values’ undeclared (first use in this function)
HGraf.c:788: error: ‘gcs’ undeclared (first use in this function)
HGraf.c:788: warning: implicit declaration of function ‘XCreateGC’
HGraf.c:788: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:788: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:790: error: ‘GCPlaneMask’ undeclared (first use in this function)
HGraf.c: In function ‘InitGlobals’:
HGraf.c:800: warning: implicit declaration of function ‘DefaultScreen’
HGraf.c:800: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:801: error: ‘theCmap’ undeclared (first use in this function)
HGraf.c:801: warning: implicit declaration of function ‘DefaultColormap’
HGraf.c:802: error: ‘rootW’ undeclared (first use in this function)
HGraf.c:802: warning: implicit declaration of function ‘RootWindow’
HGraf.c:803: error: ‘theGC’ undeclared (first use in this function)
HGraf.c:803: warning: implicit declaration of function ‘DefaultGC’
HGraf.c:804: error: ‘theVisual’ undeclared (first use in this function)
HGraf.c:804: warning: implicit declaration of function ‘DefaultVisual’
HGraf.c:805: warning: implicit declaration of function ‘DisplayCells’
HGraf.c:806: warning: implicit declaration of function ‘DisplayWidth’
HGraf.c:807: warning: implicit declaration of function ‘DisplayHeight’
HGraf.c:808: warning: implicit declaration of function ‘DisplayPlanes’
HGraf.c:809: warning: implicit declaration of function ‘WhitePixel’
HGraf.c:810: warning: implicit declaration of function ‘BlackPixel’
HGraf.c: In function ‘MakeXGraf’:
HGraf.c:817: error: ‘Window’ undeclared (first use in this function)
HGraf.c:817: error: expected ‘;’ before ‘window’
HGraf.c:818: error: ‘XSetWindowAttributes’ undeclared (first use in this function)
HGraf.c:818: error: expected ‘;’ before ‘setwinattr’
HGraf.c:823: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:823: warning: implicit declaration of function ‘XOpenDisplay’
HGraf.c:824: warning: implicit declaration of function ‘XDisplayName’
HGraf.c:828: error: ‘parent’ undeclared (first use in this function)
HGraf.c:829: error: ‘window’ undeclared (first use in this function)
HGraf.c:829: warning: implicit declaration of function ‘XCreateSimpleWindow’
HGraf.c:831: error: ‘CWBackingStore’ undeclared (first use in this function)
HGraf.c:831: error: ‘setwinattr’ undeclared (first use in this function)
HGraf.c:831: error: ‘WhenMapped’ undeclared (first use in this function)
HGraf.c:832: warning: implicit declaration of function ‘XChangeWindowAttributes’
HGraf.c:834: error: ‘hints’ undeclared (first use in this function)
HGraf.c:834: error: ‘PPosition’ undeclared (first use in this function)
HGraf.c:834: error: ‘PSize’ undeclared (first use in this function)
HGraf.c:834: error: ‘PMaxSize’ undeclared (first use in this function)
HGraf.c:834: error: ‘PMinSize’ undeclared (first use in this function)
HGraf.c:841: warning: implicit declaration of function ‘XSetStandardProperties’
HGraf.c:841: error: ‘None’ undeclared (first use in this function)
HGraf.c:843: warning: implicit declaration of function ‘XSelectInput’
HGraf.c:843: error: ‘ExposureMask’ undeclared (first use in this function)
HGraf.c:843: error: ‘KeyPressMask’ undeclared (first use in this function)
HGraf.c:843: error: ‘ButtonPressMask’ undeclared (first use in this function)
HGraf.c:844: error: ‘ButtonReleaseMask’ undeclared (first use in this function)
HGraf.c:844: error: ‘PointerMotionHintMask’ undeclared (first use in this function)
HGraf.c:844: error: ‘PointerMotionMask’ undeclared (first use in this function)
HGraf.c:845: warning: implicit declaration of function ‘XMapWindow’
HGraf.c:845: error: ‘theWindow’ undeclared (first use in this function)
HGraf.c:850: error: ‘report’ undeclared (first use in this function)
HGraf.c:851: error: ‘Expose’ undeclared (first use in this function)
HGraf.c:852: warning: implicit declaration of function ‘XSendEvent’
HGraf.c:852: error: ‘False’ undeclared (first use in this function)
HGraf.c: In function ‘TermHGraf’:
HGraf.c:861: error: ‘theDisp’ undeclared (first use in this function)
HGraf.c:862: warning: implicit declaration of function ‘XCloseDisplay’
make[1]: *** [HGraf.o] Error 1
make[1]: Leaving directory `/home/charles/bin/htk-3.4/HTKLib'
make: *** [HTKLib/HTKLib.a] Error 1

Thank you for any help you can provide. 感谢您提供任何帮助。

The very first error may indicate the cause: 第一个错误可能表明原因:

error: X11/Xlib.h: No such file or directory

At one time one needed to set $INCLUDE_PATH for gcc. 有一次需要为gcc设置$ INCLUDE_PATH。

So, the presence of a makefile.in indicates that the program is using autoconf. 因此,makefile.in的存在表明程序正在使用autoconf。 That being the case, I suggest you put both the makefile and makefile.in back the way they were, and instead redo the configure step: 既然如此,我建议你把makefile和makefile.in放回原来的样子,而是重做configure步骤:

GCC_VERSION=3.4.0 PREFIX=/usr/local/gcc/${GCC_VERSION}/bin/ CC=${PREFIX}gcc CPP=${PREFIX}g++ ./configure

Obviously, you should edit that to match the actual version of the compiler and path where you installed it, along with adding any extra configure arguments you need. 显然,您应该编辑它以匹配编译器的实际版本和安装它的路径,以及添加所需的任何额外配置参数。

在我看来,你错过了X11开发包。

Are you sure you have the X11-devel package installed? 您确定已安装X11-devel软件包吗? Looks like an abject lack of X11 header files. 看起来像是缺少X11头文件。

Install the gcc-3.4 from Ubuntu repos ( sudo apt-get install gcc-4.3 ). 从Ubuntu repos安装gcc-3.4sudo apt-get install gcc-4.3 )。

Then configure the project using ./configure CC="gcc-4.3" and make as usual. 然后使用./configure CC="gcc-4.3"配置项目并照常进行。

This might not work, but point you in the right direction. 这可能不起作用,但指向正确的方向。

EDIT: The X11 development libraries on Ubuntu are named libx11-dev but they might not be the only development libraries you are missing: read the errors and try to guess what other libraries you are missing (if you note that a header is missing try searching http://packages.ubuntu.com for the file name and add the relative package using sudo apt-get install ). 编辑:Ubuntu上的X11开发库名为libx11-dev但它们可能不是您唯一缺少的开发库:读取错误并尝试猜测您缺少的其他库(如果您注意到缺少标题,请尝试搜索http://packages.ubuntu.com获取文件名,并使用sudo apt-get install添加相关包。

The first set of errors is 第一组错误是

HGraf.c:73:77: error: X11/Xlib.h: No such file or directory 
HGraf.c:74:23: error: X11/Xutil.h: No such file or directory 
HGraf.c:75:21: error: X11/Xos.h: No such file or directory 
HGraf.c:77:27: error: X11/keysymdef.h: No such file or directory

ie your compiler can't find the X11 headers. 即您的编译器找不到X11标头。 These will probably be somewhere like /usr/X11R6/include . 这些可能就像/usr/X11R6/include Try adding that include path to your make command, like 尝试添加包含make命令的路径,例如

make CFLAGS="$CFLAGS -I/usr/X11R6/include"

If the makefile is nonstandard you might have to edit it to insert this path. 如果makefile是非标准的,您可能需要编辑它以插入此路径。 If you've run a configure script reconfigure with 如果您运行配置脚本重新配置

./configure CFLAGS="$CFLAGS -I/usr/X11R6/include" # Include any other options

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM