EnterpriseDB / mongo_fdw

PostgreSQL foreign data wrapper for MongoDB
GNU Lesser General Public License v3.0
326 stars 70 forks source link

Getting error on during "Make" #37

Closed denishpatel closed 6 years ago

denishpatel commented 9 years ago

Hello,

I'm trying to compile/ install mongo_fdw on Amazon Linux AMI server...

./autogen.sh --with-legacy

Getting following error ...

mongo_fdw]# make gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -fpic --std=c99 -Imongo-c-driver/src -Ijson-c -I. -I./ -I/usr/include/pgsql94/server -I/usr/include/pgsql94/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o mongo_wrapper.o mongo_wrapper.c mongo_wrapper.c: In function ‘JsonToBsonAppendElement’: mongo_wrapper.c:399:4: warning: ‘json_object_object_get’ is deprecated (declared at json-c/json_object.h:290) [-Wdeprecated-declarations] joj = json_object_object_get(v, "$oid"); ^ mongo_wrapper.c:405:5: warning: passing argument 2 of ‘BsonOidFromString’ discards ‘const’ qualifier from pointer target type [enabled by default] BsonOidFromString(&bsonObjectId, json_object_get_string(joj)); ^ mongowrapper.c:260:1: note: expected ‘char ’ but argument is of type ‘const char ’ BsonOidFromString(bson_oid_t o, char_ str) ^ mongo_wrapper.c:409:4: warning: ‘json_object_object_get’ is deprecated (declared at json-c/json_object.h:290) [-Wdeprecated-declarations] joj = json_object_object_get( v, "$date" ); ^ In file included from json-c/linkhash.h:16:0, from json-c/json.h:22, from mongo_wrapper.h:30, from mongo_wrapper.c:19: json-c/json_object.h:355:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] char _key;\ ^ mongo_wrapper.c:417:4: note: in expansion of macro ‘json_object_object_foreach’ json_object_object_foreach(v, kk, vv) ^ make -C mongo-c-driver src/bson.os make[1]: Entering directory /home/denishpatel/mongo_fdw/mongo-c-driver' cc -o src/bson.os -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT -fPIC -DMONGO_DLL_BUILD src/bson.c make[1]: Leaving directory/home/denishpatel/mongo_fdw/mongo-c-driver' make -C mongo-c-driver src/encoding.os make[1]: Entering directory /home/denishpatel/mongo_fdw/mongo-c-driver' cc -o src/encoding.os -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT -fPIC -DMONGO_DLL_BUILD src/encoding.c make[1]: Leaving directory/home/denishpatel/mongo_fdw/mongo-c-driver' make -C mongo-c-driver src/md5.os make[1]: Entering directory /home/denishpatel/mongo_fdw/mongo-c-driver' cc -o src/md5.os -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT -fPIC -DMONGO_DLL_BUILD src/md5.c make[1]: Leaving directory/home/denishpatel/mongo_fdw/mongo-c-driver' make -C mongo-c-driver src/mongo.os make[1]: Entering directory /home/denishpatel/mongo_fdw/mongo-c-driver' cc -o src/mongo.os -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT -fPIC -DMONGO_DLL_BUILD src/mongo.c make[1]: Leaving directory/home/denishpatel/mongo_fdw/mongo-c-driver' make -C mongo-c-driver src/numbers.os make[1]: Entering directory /home/denishpatel/mongo_fdw/mongo-c-driver' cc -o src/numbers.os -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT -fPIC -DMONGO_DLL_BUILD src/numbers.c make[1]: Leaving directory/home/denishpatel/mongo_fdw/mongo-c-driver' make -C mongo-c-driver src/env.os make[1]: Entering directory /home/denishpatel/mongo_fdw/mongo-c-driver' cc -o src/env.os -c -std=c99 -pedantic -O3 -Wall -ggdb -D_POSIX_SOURCE -DMONGO_HAVE_STDINT -fPIC -DMONGO_DLL_BUILD src/env.c make[1]: Leaving directory/home/denishpatel/mongo_fdw/mongo-c-driver' gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -fpic -shared -o mongo_fdw.so connection.o option.o mongo_wrapper.o mongo_fdw.o mongo_query.o mongo-c-driver/src/bson.os mongo-c-driver/src/encoding.os mongo-c-driver/src/md5.os mongo-c-driver/src/mongo.os mongo-c-driver/src/numbers.os mongo-c-driver/src/env.os json-c/json_util.o json-c/json_object.o json-c/json_tokener.o json-c/json_object_iterator.o json-c/printbuf.o json-c/linkhash.o json-c/arraylist.o json-c/random_seed.o json-c/debug.o -L/usr/lib64/pgsql94 -Wl,--as-needed /usr/bin/ld: json-c/json_util.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC json-c/jsonutil.o: could not read symbols: Bad value collect2: error: ld returned 1 exit status make: ** [mongo_fdw.so] Error 1

any help will be appreciated.

Thanks!

andreabat commented 9 years ago

I got the same error. Managed to make it work by launching immediately after fail.

make clean && make && make install

it then installs.

BTW I built a docker image with postgres + mongo_fdw compiled (https://hub.docker.com/r/andreabat/postgres-mongo-fdw/)

aberenyi commented 8 years ago

+1 same here.

FYI REL-4.0.0 snapshot builds just fine.

aberenyi commented 8 years ago

@andreabat strange enough, but your solution works. However, it should build out of the box as I'm trying to uprev the AUR mongo_fdw package.

maxpdx commented 8 years ago

I had the same issue. The fix is to add --enable-shared configure argument to autogen.sh,

function install_json_lib
{
        cd json-c
        sh ./autogen.sh
        ./configure --enable-shared
        make install
        cd ..
}