zini2001
07-04-2005, 22:38
hallo ....
folgendes programm möchte ich auf mehrere dateien aufteilen.
eine main.c, graphmain.c und graphmain.h .
original: (nach dem tut von http://enchantia.com/software/graphapp/)
#include <stdio.h>
#include "graphapp.h"
//#include "graphmain.h" !!!EDIT
void redraw_it(Window *w, Graphics *g);
int main(int argc, char *argv[])
{
App *app = new_app(argc, argv);
Window *w = new_window(app,rect(20,20,350,250),"test",STANDARD_WINDOW);
on_window_redraw(w, redraw_it);
show_window(w);
main_loop(app);
return 0;
}
void graph(Window *w, Graphics *g)
{
new_label(w,rect(0,0,100,30),"hallo zini",ALIGN_LEFT);
}
mit diesem makefile kann ich das programm erzeugen und klappt!
makefile:
CC = gcc -g
APP_PATH = /home/warnekes/app/src
APP_LIB = app
X11 = /usr/X11R6
X11LIB = $(X11)/lib
LIBS = -lX11 -lc -lm
DYNALINK = -Xlinker -rpath -Xlinker $(APP_PATH)
CFLAGS = -I$(APP_PATH)
DYNAMIC = -L$(APP_PATH) -l$(APP_LIB) -L$(X11LIB) $(LIBS) $(DYNALINK)
STATIC = $(APP_PATH)/lib$(APP_LIB).a -L$(X11LIB) $(LIBS)
TARGET = main
SRC = main.o
static: $(SRC)
# Creating the static version.
# Try "make dynamic" for a smaller executable size.
$(CC) $(CFLAGS) $(SRC) $(STATIC) -o $(TARGET)
dynamic: $(SRC)
# Creating the dynamic version.
# Try "make static" if this has problems.
$(CC) $(CFLAGS) $(SRC) $(DYNAMIC) -o $(TARGET)
test: main.o
$(CC) $(CFLAGS) $(SRC) $(DYNAMIC) -o $(TARGET)
clean:
rm -f core *.o $(TARGETS)
main.c:
#include <stdio.h>
#include "graphmain.h"
void redraw_it(Window *w, Graphics *g);
int main(int argc, char *argv[])
{
App *app = new_app(argc, argv);
Window *w = new_window(app,rect(20,20,350,250),"test",STANDARD_WINDOW);
on_window_redraw(w, redraw_it);
show_window(w);
main_loop(app);
return 0;
}
graphmain.c:
#include "graphmain.h"
void graph(Window *w, Graphics *g)
{
new_label(w,rect(0,0,100,30),"hallo zini",ALIGN_LEFT);
}
grapmain.h:
#ifndef _graphmain_h
#define _graphmain_h
#include <stdio.h>
#include "graphapp.h" // !!!EDIT
void redraw_it(Window *w, Graphics *g);
#endif
nach div. anleitungen und makefiles hab ich mir das hier zusammengebastelt.
makefile: (dieses makefile hab ich mir zusammen geklaut)
CC = gcc -g
APP_PATH = /home/warnekes/app/src
APP_LIB = app
X11 = /usr/X11R6
X11LIB = $(X11)/lib
LIBS = -lX11 -lc -lm
DYNALINK = -Xlinker -rpath -Xlinker $(APP_PATH)
CFLAGS = -I$(APP_PATH)
DYNAMIC = -L$(APP_PATH) -l$(APP_LIB) -L$(X11LIB) $(LIBS) #$(DYNALINK)
STATIC = $(APP_PATH)/lib$(APP_LIB).a -L$(X11LIB) $(LIBS)
TARGET = main
SRC = main.o graphmain.o
static: $(SRC)
# Creating the static version.
# Try "make dynamic" for a smaller executable size.
$(CC) $(CFLAGS) $(SRC) $(STATIC) -o $(TARGET)
dynamic: main.o
# Creating the dynamic version.
# Try "make static" if this has problems.
$(CC) $(CFLAGS) $(SRC) $(DYNAMIC) -o $(TARGET)
main.o: main.o graphmain.h
$(CC) -c $(CFLAGS) main.o main.c $(DYNAMIC)
graphmain.o: main.o graphmain.h
$(CC) -c $(CFLAGS) graphmain.o graphmain.c $(DYNAMIC)
clean:
rm -f core *.o $(TARGETS)
fehlermeldung:
warnekes@henderson:~/FHH/sse-ssn/test_uebersicht> make
gcc -O -I/usr/X11R6/include -I/home/warnekes/app/src -c -o main.o main.c
In file included from main.c:2:
graphmain.h:7: error: parse error before '*' token
main.c: In function `main':
main.c:7: error: `App' undeclared (first use in this function)
main.c:7: error: (Each undeclared identifier is reported only once
main.c:7: error: for each function it appears in.)
main.c:7: error: `app' undeclared (first use in this function)
main.c:8: error: `Window' undeclared (first use in this function)
main.c:8: error: `w' undeclared (first use in this function)
main.c:8: error: `STANDARD_WINDOW' undeclared (first use in this function)
make: *** [main.o] Fehler 1
warnekes@henderson:~/FHH/sse-ssn/test_uebersicht>
mir ist nicht ganz klar wie ich die makefiles zu benutzen habe.
wie und was muß ich im makefile umschreiben, um mehrere dateien einzulinken?
mag mir jemand helfen?
gruß
folgendes programm möchte ich auf mehrere dateien aufteilen.
eine main.c, graphmain.c und graphmain.h .
original: (nach dem tut von http://enchantia.com/software/graphapp/)
#include <stdio.h>
#include "graphapp.h"
//#include "graphmain.h" !!!EDIT
void redraw_it(Window *w, Graphics *g);
int main(int argc, char *argv[])
{
App *app = new_app(argc, argv);
Window *w = new_window(app,rect(20,20,350,250),"test",STANDARD_WINDOW);
on_window_redraw(w, redraw_it);
show_window(w);
main_loop(app);
return 0;
}
void graph(Window *w, Graphics *g)
{
new_label(w,rect(0,0,100,30),"hallo zini",ALIGN_LEFT);
}
mit diesem makefile kann ich das programm erzeugen und klappt!
makefile:
CC = gcc -g
APP_PATH = /home/warnekes/app/src
APP_LIB = app
X11 = /usr/X11R6
X11LIB = $(X11)/lib
LIBS = -lX11 -lc -lm
DYNALINK = -Xlinker -rpath -Xlinker $(APP_PATH)
CFLAGS = -I$(APP_PATH)
DYNAMIC = -L$(APP_PATH) -l$(APP_LIB) -L$(X11LIB) $(LIBS) $(DYNALINK)
STATIC = $(APP_PATH)/lib$(APP_LIB).a -L$(X11LIB) $(LIBS)
TARGET = main
SRC = main.o
static: $(SRC)
# Creating the static version.
# Try "make dynamic" for a smaller executable size.
$(CC) $(CFLAGS) $(SRC) $(STATIC) -o $(TARGET)
dynamic: $(SRC)
# Creating the dynamic version.
# Try "make static" if this has problems.
$(CC) $(CFLAGS) $(SRC) $(DYNAMIC) -o $(TARGET)
test: main.o
$(CC) $(CFLAGS) $(SRC) $(DYNAMIC) -o $(TARGET)
clean:
rm -f core *.o $(TARGETS)
main.c:
#include <stdio.h>
#include "graphmain.h"
void redraw_it(Window *w, Graphics *g);
int main(int argc, char *argv[])
{
App *app = new_app(argc, argv);
Window *w = new_window(app,rect(20,20,350,250),"test",STANDARD_WINDOW);
on_window_redraw(w, redraw_it);
show_window(w);
main_loop(app);
return 0;
}
graphmain.c:
#include "graphmain.h"
void graph(Window *w, Graphics *g)
{
new_label(w,rect(0,0,100,30),"hallo zini",ALIGN_LEFT);
}
grapmain.h:
#ifndef _graphmain_h
#define _graphmain_h
#include <stdio.h>
#include "graphapp.h" // !!!EDIT
void redraw_it(Window *w, Graphics *g);
#endif
nach div. anleitungen und makefiles hab ich mir das hier zusammengebastelt.
makefile: (dieses makefile hab ich mir zusammen geklaut)
CC = gcc -g
APP_PATH = /home/warnekes/app/src
APP_LIB = app
X11 = /usr/X11R6
X11LIB = $(X11)/lib
LIBS = -lX11 -lc -lm
DYNALINK = -Xlinker -rpath -Xlinker $(APP_PATH)
CFLAGS = -I$(APP_PATH)
DYNAMIC = -L$(APP_PATH) -l$(APP_LIB) -L$(X11LIB) $(LIBS) #$(DYNALINK)
STATIC = $(APP_PATH)/lib$(APP_LIB).a -L$(X11LIB) $(LIBS)
TARGET = main
SRC = main.o graphmain.o
static: $(SRC)
# Creating the static version.
# Try "make dynamic" for a smaller executable size.
$(CC) $(CFLAGS) $(SRC) $(STATIC) -o $(TARGET)
dynamic: main.o
# Creating the dynamic version.
# Try "make static" if this has problems.
$(CC) $(CFLAGS) $(SRC) $(DYNAMIC) -o $(TARGET)
main.o: main.o graphmain.h
$(CC) -c $(CFLAGS) main.o main.c $(DYNAMIC)
graphmain.o: main.o graphmain.h
$(CC) -c $(CFLAGS) graphmain.o graphmain.c $(DYNAMIC)
clean:
rm -f core *.o $(TARGETS)
fehlermeldung:
warnekes@henderson:~/FHH/sse-ssn/test_uebersicht> make
gcc -O -I/usr/X11R6/include -I/home/warnekes/app/src -c -o main.o main.c
In file included from main.c:2:
graphmain.h:7: error: parse error before '*' token
main.c: In function `main':
main.c:7: error: `App' undeclared (first use in this function)
main.c:7: error: (Each undeclared identifier is reported only once
main.c:7: error: for each function it appears in.)
main.c:7: error: `app' undeclared (first use in this function)
main.c:8: error: `Window' undeclared (first use in this function)
main.c:8: error: `w' undeclared (first use in this function)
main.c:8: error: `STANDARD_WINDOW' undeclared (first use in this function)
make: *** [main.o] Fehler 1
warnekes@henderson:~/FHH/sse-ssn/test_uebersicht>
mir ist nicht ganz klar wie ich die makefiles zu benutzen habe.
wie und was muß ich im makefile umschreiben, um mehrere dateien einzulinken?
mag mir jemand helfen?
gruß