简体   繁体   中英

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

I instead installed two versions of gcc 3.4 - 3.4.0 and 3.4.6 using instructions from this site. 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. I also tried, on the off-chance, compiling it with my current version (4.4.1), but that also failed. 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.

So, the presence of a makefile.in indicates that the program is using 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:

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? Looks like an abject lack of X11 header files.

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

Then configure the project using ./configure CC="gcc-4.3" and make as usual.

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

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. These will probably be somewhere like /usr/X11R6/include . Try adding that include path to your make command, like

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

If the makefile is nonstandard you might have to edit it to insert this path. If you've run a configure script reconfigure with

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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