Sziasztok! A következő probléma megoldásához kérek segítséget:
Van egy C forrásfile, amiben szerepel a
#include X11/Xlib.h
#include sys/types.h
részlet.
gcc-vel nem sikerült lefordítani. Így próbáltam:
gcc forras.c -o futtathato -lX11
Erre fosott egy halom hibaüzenetet, gondolom a types.h-val összefüggő programrészekkel van baja.
A kérdésem: Milyen gcc kapcsolóval lehet ezt a types.h-t megetetni a fordítóval? Valami libraryt kell linkelni még, amit kihagytam? man gcc -ben nem találtam meg a megoldást, és most a google sem volt a barátom. Minden segítséget előre is köszönök.
Ui: include után a "kacsacsőröket" kivettem mert nem jelennek meg a fórum szövegében, de természetesen a forrásfile-ban ott vannak szabályosan.
- 4781 megtekintés
Hozzászólások
Halom hibaüzenet?
- A hozzászóláshoz be kell jelentkezni
xlib_sample.c: In function ‘main’:
xlib_sample.c:30:5: error: stray ‘\342’ in program
xlib_sample.c:30:5: error: stray ‘\200’ in program
xlib_sample.c:30:5: error: stray ‘\234’ in program
xlib_sample.c:30:26: error: ‘VM’ undeclared (first use in this function)
xlib_sample.c:30:26: note: each undeclared identifier is reported only once for each function it appears in
xlib_sample.c:30:29: error: ‘CMS’ undeclared (first use in this function)
xlib_sample.c:30:33: error: expected ‘)’ before ‘X’
xlib_sample.c:30:33: error: stray ‘\342’ in program
xlib_sample.c:30:33: error: stray ‘\200’ in program
xlib_sample.c:30:33: error: stray ‘\235’ in program
xlib_sample.c:31:5: error: stray ‘\342’ in program
xlib_sample.c:31:5: error: stray ‘\200’ in program
xlib_sample.c:31:5: error: stray ‘\234’ in program
xlib_sample.c:31:28: error: ‘X’ undeclared (first use in this function)
xlib_sample.c:31:30: error: expected ‘)’ before ‘Sample’
xlib_sample.c:31:30: error: stray ‘\342’ in program
xlib_sample.c:31:30: error: stray ‘\200’ in program
xlib_sample.c:31:30: error: stray ‘\235’ in program
xlib_sample.c:46:5: error: stray ‘\342’ in program
xlib_sample.c:46:5: error: stray ‘\200’ in program
xlib_sample.c:46:5: error: stray ‘\234’ in program
xlib_sample.c:46:24: error: ‘Going’ undeclared (first use in this function)
xlib_sample.c:46:30: error: expected ‘)’ before ‘to’
xlib_sample.c:46:30: error: stray ‘\’ in program
xlib_sample.c:46:30: error: stray ‘\342’ in program
xlib_sample.c:46:30: error: stray ‘\200’ in program
xlib_sample.c:46:30: error: stray ‘\235’ in program
xlib_sample.c:47:5: error: stray ‘\342’ in program
xlib_sample.c:47:5: error: stray ‘\200’ in program
xlib_sample.c:47:5: error: stray ‘\234’ in program
xlib_sample.c:47:15: error: ‘CP’ undeclared (first use in this function)
xlib_sample.c:47:18: error: expected ‘)’ before ‘SLEEP’
xlib_sample.c:47:18: error: stray ‘\342’ in program
xlib_sample.c:47:18: error: stray ‘\200’ in program
xlib_sample.c:47:18: error: stray ‘\235’ in program
xlib_sample.c:48:5: error: stray ‘\342’ in program
xlib_sample.c:48:5: error: stray ‘\200’ in program
xlib_sample.c:48:5: error: stray ‘\234’ in program
xlib_sample.c:48:24: error: ‘Okay’ undeclared (first use in this function)
xlib_sample.c:48:30: error: ‘back’ undeclared (first use in this function)
xlib_sample.c:48:34: error: expected ‘)’ before ‘!’ token
xlib_sample.c:48:34: error: stray ‘\’ in program
xlib_sample.c:48:34: error: stray ‘\342’ in program
xlib_sample.c:48:34: error: stray ‘\200’ in program
xlib_sample.c:48:34: error: stray ‘\235’ in program
- A hozzászóláshoz be kell jelentkezni
Ez pedig a forrás:
/*
* This is an X window program using X11 API,
* that opens the display and creates a window, waits
* 60 seconds, then destroys the window before ending.
*/
#include
#include
#include
main(argc, argv)
int argc;
char *argv[];
{
Display *dp;
Window w;
/*
* X will lookup the value of the DISPLAY global variable in
* the CENV group when passed a NULL pointer in XOpenDisplay.
*/
dp = XOpenDisplay(NULL);
/*
* Create a 200X200 window at xy(40,40) with black border and name.
*/
w = XCreateSimpleWindow(dp, RootWindow(dp, 0),
40, 40, 200, 200, 2, BlackPixel(dp, 0),
WhitePixel(dp, 0));
XStoreName(dp, w, “VM/CMS X Sample”);
XSetIconName(dp, w, “X Sample”);
/*
* Map the window to the display.
* This will cause the window to become visible on the screen.
*/
XMapWindow(dp, w);
/*
* Force X to write buffered requests.
*/
XFlush(dp);
fprintf(stderr, “Going to sleep now.... 60 seconds...\n”);
system(“CP SLEEP 60 SEC”);
fprintf(stderr, “Okay, back!\n”);
/*
* Destroy the window and end the connection to the X Server.
*/
XDestroyWindow(dp, w);
XCloseDisplay(dp);
}
Nem én írtam csak tanulási céllal foglalkozok vele. Neten találtam már meg nem mondom, hol.
- A hozzászóláshoz be kell jelentkezni
Miből gondoltad, hogy a types.h-val van baj, és nem az idézőjelnek kinéző, de nem " karakterekkel? Header fájlt nem is lehet linkelni, csak definíciók vannak benne, nem kód. Szerintem tegyél hátrafelé két lépést, mielőtt következtetésekre jutsz, mert így még a kérdés is hibás :)
- A hozzászóláshoz be kell jelentkezni
Nem a types.h-t akartam linkelni csak arra gondoltam, hogy a gcc vár még valami opciót vagy könyvtárat talán, ami kell a fordításhoz, csak nem tudom, mit.Köszi az idézőjeles észrevételt, megpróbálom javítás után mégegyszer.
Hogyarosseb......!
Ez volt a megoldás. Köszönöm! LoL.....
- A hozzászóláshoz be kell jelentkezni
pörgessél
- A hozzászóláshoz be kell jelentkezni
:D rég hallottam, de amúgy téllegmennyenpörgetni.
- A hozzászóláshoz be kell jelentkezni