Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation issue. on ubuntu - 12.04. mongodb driver is installed. #331

Closed
sseshachala opened this issue May 21, 2013 · 6 comments
Closed
Labels
Bug A genuine bug

Comments

@sseshachala
Copy link

libtool: link: gcc -Wall -Werror -g -O2 -o .libs/collectd-nagios collectd_nagios-collectd-nagios.o libcollectdclient/.libs/libcollectdclient.so -L/usr/lib -L/lib/x86_64-linux-gnu -lgcrypt -ldl

write_mongodb.c:77:3: error: implicit declaration of function ‘bson_create’ [-Werror=implicit-function-declaration]
write_mongodb.c:77:7: error: assignment makes pointer from integer without a cast [-Werror]
write_mongodb.c: In function ‘wm_write’:
write_mongodb.c:246:3: error: implicit declaration of function ‘bson_dispose’ [-Werror=implicit-function-declaration

Can some one shed some light?

@ymettier
Copy link
Contributor

Hello,

I followed part of this problem in github perfwatcher/perfwatcher issue #31. I redirected @sseshachala here because there is no modification of the code related to mongodb in the patchs we provide for collectd to work better with perfwatcher.

I think I will not help too much (I do not use mongodb), but maybe the answer of those 2 questions may help others to help you :

  • how and were did you install mongodb ? Is it with apt-get install (or any Ubuntu standard packaging system) or have you compiled it ? What version is it ?
  • could you provide the configure --with-libmongoc... you used to compile collectd ?

Regards,
Yves

@octo
Copy link
Member

octo commented May 26, 2013

Hi,

"implicit declaration" means that the function is being used (called) but that it was not declared. The declaration should happen in the appropriate header file, so either a header file is missing or we need to include an additional header file on Ubuntu. Anyway, this hints at a compile time issue.

The first line you posted, however, suggest that your problem appears at link time. Can you please search for the bson_create function in your header files, e.g. with: grep -r bson_create /usr/include

Also, please provide a bit more context, e.g. the 20 lines leading up to the error.

Thanks and best regards,
—octo

@jiangytcn
Copy link

Hi, below is my installation process:

[root@stackdev collectd]# ls /usr/local/lib/libmongoc.*
/usr/local/lib/libmongoc.a   /usr/local/lib/libmongoc.so.0.7
/usr/local/lib/libmongoc.so  /usr/local/lib/libmongoc.so.0.7.1
./configure --enable-write_mongodb --prefix=/usr/local/etc/collectd/ --with-libmongoc=/usr/local/

and here all works fine, but when i run make && make install, it caused errorf as belows:

/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.  -DPREFIX='"/usr/local/etc/collectd"' -DCONFIGFILE='"/usr/local/etc/collectd/etc/collectd.conf"' -DLOCALSTATEDIR='"/usr/local/etc/collectd/var"' -DPKGLOCALSTATEDIR='"/usr/local/etc/collectd/var/lib/collectd"' -DPIDFILE='"/usr/local/etc/collectd/var/run/collectd.pid"' -DPLUGINDIR='"/usr/local/etc/collectd/lib/collectd"' -DPKGDATADIR='"/usr/local/etc/collectd/share/collectd"'  -Wall -Werror  -g -O2 -MT write_http_la-utils_format_json.lo -MD -MP -MF .deps/write_http_la-utils_format_json.Tpo -c -o write_http_la-utils_format_json.lo `test -f 'utils_format_json.c' || echo './'`utils_format_json.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -DPREFIX=\"/usr/local/etc/collectd\" -DCONFIGFILE=\"/usr/local/etc/collectd/etc/collectd.conf\" -DLOCALSTATEDIR=\"/usr/local/etc/collectd/var\" -DPKGLOCALSTATEDIR=\"/usr/local/etc/collectd/var/lib/collectd\" -DPIDFILE=\"/usr/local/etc/collectd/var/run/collectd.pid\" -DPLUGINDIR=\"/usr/local/etc/collectd/lib/collectd\" -DPKGDATADIR=\"/usr/local/etc/collectd/share/collectd\" -Wall -Werror -g -O2 -MT write_http_la-utils_format_json.lo -MD -MP -MF .deps/write_http_la-utils_format_json.Tpo -c utils_format_json.c  -fPIC -DPIC -o .libs/write_http_la-utils_format_json.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -DPREFIX=\"/usr/local/etc/collectd\" -DCONFIGFILE=\"/usr/local/etc/collectd/etc/collectd.conf\" -DLOCALSTATEDIR=\"/usr/local/etc/collectd/var\" -DPKGLOCALSTATEDIR=\"/usr/local/etc/collectd/var/lib/collectd\" -DPIDFILE=\"/usr/local/etc/collectd/var/run/collectd.pid\" -DPLUGINDIR=\"/usr/local/etc/collectd/lib/collectd\" -DPKGDATADIR=\"/usr/local/etc/collectd/share/collectd\" -Wall -Werror -g -O2 -MT write_http_la-utils_format_json.lo -MD -MP -MF .deps/write_http_la-utils_format_json.Tpo -c utils_format_json.c -o write_http_la-utils_format_json.o >/dev/null 2>&1
mv -f .deps/write_http_la-utils_format_json.Tpo .deps/write_http_la-utils_format_json.Plo
/bin/sh ../libtool --tag=CC   --mode=link gcc -Wall -Werror  -g -O2 -module -avoid-version  -o write_http.la -rpath /usr/local/etc/collectd/lib/collectd write_http_la-write_http.lo write_http_la-utils_format_json.lo -lcurl   -ldl 
libtool: link: gcc -shared  -fPIC -DPIC  .libs/write_http_la-write_http.o .libs/write_http_la-utils_format_json.o   -lcurl -ldl  -O2   -Wl,-soname -Wl,write_http.so -o .libs/write_http.so
libtool: link: ar cru .libs/write_http.a  write_http_la-write_http.o write_http_la-utils_format_json.o
libtool: link: ranlib .libs/write_http.a
libtool: link: ( cd ".libs" && rm -f "write_http.la" && ln -s "../write_http.la" "write_http.la" )
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.  -DPREFIX='"/usr/local/etc/collectd"' -DCONFIGFILE='"/usr/local/etc/collectd/etc/collectd.conf"' -DLOCALSTATEDIR='"/usr/local/etc/collectd/var"' -DPKGLOCALSTATEDIR='"/usr/local/etc/collectd/var/lib/collectd"' -DPIDFILE='"/usr/local/etc/collectd/var/run/collectd.pid"' -DPLUGINDIR='"/usr/local/etc/collectd/lib/collectd"' -DPKGDATADIR='"/usr/local/etc/collectd/share/collectd"' -I/usr/local//include  -Wall -Werror -g -O2 -MT write_mongodb_la-write_mongodb.lo -MD -MP -MF .deps/write_mongodb_la-write_mongodb.Tpo -c -o write_mongodb_la-write_mongodb.lo `test -f 'write_mongodb.c' || echo './'`write_mongodb.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -DPREFIX=\"/usr/local/etc/collectd\" -DCONFIGFILE=\"/usr/local/etc/collectd/etc/collectd.conf\" -DLOCALSTATEDIR=\"/usr/local/etc/collectd/var\" -DPKGLOCALSTATEDIR=\"/usr/local/etc/collectd/var/lib/collectd\" -DPIDFILE=\"/usr/local/etc/collectd/var/run/collectd.pid\" -DPLUGINDIR=\"/usr/local/etc/collectd/lib/collectd\" -DPKGDATADIR=\"/usr/local/etc/collectd/share/collectd\" -I/usr/local//include -Wall -Werror -g -O2 -MT write_mongodb_la-write_mongodb.lo -MD -MP -MF .deps/write_mongodb_la-write_mongodb.Tpo -c write_mongodb.c  -fPIC -DPIC -o .libs/write_mongodb_la-write_mongodb.o
write_mongodb.c: In function 'wm_create_bson':
write_mongodb.c:77:3: error: implicit declaration of function 'bson_create' [-Werror=implicit-function-declaration]
write_mongodb.c:77:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
write_mongodb.c: In function 'wm_write':
write_mongodb.c:246:3: error: implicit declaration of function 'bson_dispose' [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
make[3]: *** [write_mongodb_la-write_mongodb.lo] Error 1
make[3]: Leaving directory `/opt/sources/collectd/src'
make[2]: *** [all-recursive] Error 1

Thanks.

@octo
Copy link
Member

octo commented Jun 16, 2013

I'm pretty sure the cause is that --enable-write_mongodb doesn't do what you expect it to be doing: The configure script determines which libraries are available and enables those whose dependencies are met.

The --enable-write_mongodb is meant for package maintainers only: The plugin is forcefully enabled, even if its dependencies are missing, so that it does fail and maintainers don't build packages with missing plugins by accident.

Please look through the config.log file which is written by configure. It should have information on why the mongo C library was not found.

Best regards,
—octo

@ChrisLundquist
Copy link
Contributor

The issue is that the api changed in 0.8.0 https://github.com/mongodb/mongo-c-driver/blob/master/HISTORY.md#08 renaming the function to bson_alloc

octo added a commit that referenced this issue Mar 9, 2015
Thanks to @eremenko for providing the initial patch!

Fixes: #331, #956
octo added a commit that referenced this issue Mar 9, 2015
According to the mongo-c-driver 0.8.1 documentation, each call to
bson_alloc() needs to be matched by a call to bson_dealloc() and each
call to bson_init() needs to be matched by a call to bson_destroy().

Additionally, this patch adds macros for mongo-c-driver < 0.8.0 to map
the new bson_alloc() and bson_deallow() names to the old bson_create()
and bson_dispose() symbol names.

Tested with mongo-c-driver 0.8.1 and 0.7.1.

Fixes: #331, #956
@octo
Copy link
Member

octo commented Mar 9, 2015

This latest patch adds compatibility for (at least) mongo-c-driver 0.8.1 and 0.7.1. However, the driver has been completely rewritten it seems, with even more API and ABI changes. This will be a matter for a new feature release, though.

@octo octo closed this as completed Mar 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A genuine bug
Projects
None yet
Development

No branches or pull requests

5 participants