|
There seems to be a bit of a mess with SConstruct and Makefile.
I'm gonna bundle all of my observations together, sorry, I don't know how to quite sort them out.
1) Building with Makefile is broken. See, the produced .so file(s) have no actual exported symbols in them.
[vps@druid]~/ws/EF/mongo-c-driver$ make
|
cc -o src/bson.o -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT src/bson.c
|
cc -o src/encoding.o -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT src/encoding.c
|
cc -o src/gridfs.o -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT src/gridfs.c
|
cc -o src/md5.o -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT src/md5.c
|
cc -o src/mongo.o -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT src/mongo.c
|
cc -o src/numbers.o -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT src/numbers.c
|
cc -o src/env_posix.o -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT src/env_posix.c
|
cc -shared -Wl,-soname,libmongoc.so.0.5 -o libmongoc.so
|
cc -shared -Wl,-soname,libbson.so.0.5 -o libbson.so
|
ar -rs libmongoc.a src/bson.o src/encoding.o src/gridfs.o src/md5.o src/mongo.o src/numbers.o src/env_posix.o
|
ar: creating libmongoc.a
|
ar -rs libbson.a src/bson.o src/numbers.o src/encoding.o
|
ar: creating libbson.a
|
[vps@druid]~/ws/EF/mongo-c-driver$ nm libmongoc.so | grep mongo
|
[vps@druid]~/ws/EF/mongo-c-driver$
|
That's because (a) the object files are not listed in the linkage command, and (b), object files are not compile with relocatable symbols.
This diff should take care of that problem:
diff --git a/Makefile b/Makefile
|
index 99c9dd8..c7bdfda 100644
|
--- a/Makefile
|
+++ b/Makefile
|
@@ -136,14 +136,17 @@ md5.o: src/md5.c src/md5.h
|
mongo.o: src/mongo.c src/mongo.h src/bson.h src/md5.h src/env.h
|
numbers.o: src/numbers.c
|
|
-$(MONGO_DYLIBNAME): $(MONGO_OBJECTS)
|
- $(MONGO_DYLIB_MAKE_CMD)
|
+DYN_MONGO_OBJECTS=$(foreach i,$(MONGO_OBJECTS),$(i)s)
|
+DYN_BSON_OBJECTS=$(foreach i,$(MONGO_OBJECTS),$(i)s)
|
+
|
+$(MONGO_DYLIBNAME): $(DYN_MONGO_OBJECTS)
|
+ $(MONGO_DYLIB_MAKE_CMD) $^
|
|
$(MONGO_STLIBNAME): $(MONGO_OBJECTS)
|
$(AR) -rs $@ $(MONGO_OBJECTS)
|
|
-$(BSON_DYLIBNAME): $(BSON_OBJECTS)
|
- $(BSON_DYLIB_MAKE_CMD)
|
+$(BSON_DYLIBNAME): $(DYN_BSON_OBJECTS)
|
+ $(BSON_DYLIB_MAKE_CMD) $^
|
|
$(BSON_STLIBNAME): $(BSON_OBJECTS)
|
$(AR) -rs $@ $(BSON_OBJECTS)
|
@@ -170,7 +173,7 @@ docs:
|
python docs/buildscripts/docs.py
|
|
clean:
|
- rm -rf $(MONGO_DYLIBNAME) $(MONGO_STLIBNAME) $(BSON_DYLIBNAME) $(BSON_STLIBNAME) src/*.o test/*_test
|
+ rm -rf $(MONGO_DYLIBNAME) $(MONGO_STLIBNAME) $(BSON_DYLIBNAME) $(BSON_STLIBNAME) src/*.o src/*.os test/*_test
|
|
deps:
|
$(CC) -MM -DMONGO_HAVE_STDINT src/*.c
|
@@ -184,4 +187,10 @@ deps:
|
%.o: %.c
|
$(CC) -o $@ -c $(ALL_CFLAGS) $<
|
|
+
|
+%.os: %.c
|
+ $(CC) -o $@ -c $(ALL_CFLAGS) $(DYN_FLAGS) $<
|
+
|
+%.os: DYN_FLAGS := -fPIC -DMONGO_DLL_BUILD
|
+
|
.PHONY: clean docs
|
Ok, now, though Makefile doesn't build right, SCons doesn't install right.
I never had any dealings with SCons before this project, so I don't know how to quite address this, but the two things to address are:
(1) Creating shared library - installing .so is not enough, because soname is set to libsome-so.ver, the dynamic linker will insist on looking for that exact file during execution. The links must be installed properly.
(2) Specifying where to install:
for installing via Makefile, you can at least do:
sudo INSTALL_INCLUDE_PATH=/usr/local/mongo-0.6/include INSTALL_LIBRARY_PATH=/usr/local/mongo-0.6/lib make install
|
but with SCons, there is no indication on how to specify where the installation should be done.
Thanks, Pawel.
|