Monday, October 30, 2006

Compiling BOINC uppercase Sample on Linux

In order to compile uppercase.C with gcc version 4.1.1, I had to change some function signatures to match their definitions, since C99 defines bool. Hopefully blogger doesn't mangle the patches given here. Just in case, there is a patch to correct the function signatures and another patch to fix OpenGL linking.
diff --git a/uppercase/uc_graphics.C b/uppercase/uc_graphics.C
index 0563dfa..4f165b9 100644
--- a/uppercase/uc_graphics.C
+++ b/uppercase/uc_graphics.C
@@ -189,7 +189,7 @@ void app_graphics_reread_prefs(){
parse_project_prefs(uc_aid.project_preferences);
}

-void boinc_app_mouse_move(int x, int y, int left, int middle, int right) {
+void boinc_app_mouse_move(int x, int y, bool left, bool middle, bool right) {
if (left) {
pitch_angle += (y-mouse_y)*.1;
roll_angle += (x-mouse_x)*.1;
@@ -205,7 +205,7 @@ void boinc_app_mouse_move(int x, int y,
}
}

-void boinc_app_mouse_button(int x, int y, int which, int is_down) {
+void boinc_app_mouse_button(int x, int y, int which, bool is_down) {
if (is_down) {
mouse_down = true;
mouse_x = x;
Also, I was trying to build uppercase, with graphics enabled. There are some files that uppercase needs to link with that are not in any of the BOINC libraries, so the must be built and linked with directly. I also changed the library handling to not be hard-wired to a given directory:
diff --git a/uppercase/Makefile b/uppercase/Makefile
index 546b748..0d275c0 100644
--- a/uppercase/Makefile
+++ b/uppercase/Makefile
@@ -17,30 +17,31 @@ CXXFLAGS = -g -L$(BOINC_LIB_DIR) -L /usr/X11R6/lib -L.
+CFLAGS = $(CXXFLAGS)

# the following should be freeglut; use nm to check
-LIBGLUT = /usr/local/lib/libglut.a
-LIBGLU = /usr/X11R6/lib/libGLU.a
-LIBJPEG = /usr/lib/libjpeg.a
+LIBGLUT = -lglut
+LIBGLU = -lGLU
+LIBJPEG = -ljpeg

PROGS = upper_case upper_case.so

all: $(PROGS)

clean:
- rm $(PROGS)
+ rm $(PROGS) upper_case.o uc_graphics.o

# the -Wl,--export-dynamic causes the main program's symbols
# to be exported to the graphics library

upper_case: upper_case.o $(BOINC_API_DIR)/libboinc_api.a $(BOINC_API_DIR)/libboinc_graphics_lib.a $(BOINC_LIB_DIR)/libboinc.a
- g++ $(CXXFLAGS) -Wl,--export-dynamic -o upper_case upper_case.o libstdc++ -pthread -lboinc_api -lboinc -lboinc_graphics_lib -ldl
+ g++ $(CXXFLAGS) -Wl,--export-dynamic -o upper_case upper_case.o -lstdc++ -pthread -lboinc_api -lboinc -lboinc_graphics_lib -ldl

-upper_case.so: uc_graphics.o $(BOINC_LIB_DIR)/libboinc.a $(BOINC_API_DIR)/libboinc_graphics_impl.a
+upper_case.so: uc_graphics.o $(BOINC_API_DIR)/txf_util.o $(BOINC_API_DIR)/texfont.o $(BOINC_LIB_DIR)/libboinc.a $(BOINC_API_DIR)/libboinc_graphics_impl.a
g++ $(CXXFLAGS) -o upper_case.so -shared -fPIC -pthread - uc_graphics.o - libstdc++ + uc_graphics.o $(BOINC_API_DIR)/txf_util.o $(BOINC_API_DIR)/texfont.o + -lstdc++ -lboinc_graphics_impl -lboinc $(LIBGLUT) $(LIBGLU) $(LIBJPEG) -lGL -lX11 -lXmu -lm

No comments: