Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22002

Undefined symbol after linking C driver dynamically

$
0
0

I am using the following make file to build an application that links against libbson and libmongoc:

CURRENT_DIR=$(shell pwd)

INC=-I/usr/local/include/libbson-1.0
INC+=-I/usr/local/include/libbson-1.0/bson
INC+=-I/usr/local/include/libmongoc-1.0/mongoc
INC+=-I$(CURRENT_DIR)/thpool
INC+=-I$(CURRENT_DIR)/cJSON

LIBS=/usr/local/lib/

all     :       request.o db_manager.o main.o
    +$(MAKE) -C cJSON all
    +$(MAKE) -C thpool all
    mkdir build
    mv cJSON/*.o build/
    mv thpool/*.o build/
    mv request.o build/
    mv db_manager.o build/
    mv main.o build/
    cp -R libs build/ #make copy of local static libs
    cd build && \
    cc $(INC) -w -pthread main.o request.o db_manager.o cJSON.o cJSON_Utils.o \
    thpool.o $(LIBS)libbson-1.0.so $(LIBS)libmongoc-1.0.so \
    -o ghost-chat

request.o       :       request.c
    cc -w $(INC) -c request.c

db_manager.o    :       db_manager.c
    cc -w $(INC) -c db_manager.c

main.o  :       main.c
    cc -w $(INC) -c main.c

clean   :
    rm -rf build

The application builds correctly, but during execution, when I make a call to a libmongoc function, it returns the following error:

./build/ghost-chat: symbol lookup error: ./build/ghost-chat: undefined symbol: mongoc_collection_insert_one

Am I correctly linking the libmongoc-1.0.so library? I have built the libmongoc driver from the latest tarball - hence the installation directory of /usr/local/*. I have tested the application successfully - using Xcode on macOS, using it's own build system, but I have written this make file to allow building on our *Nix server.

Any advice would be greatly appreciated.


Viewing all articles
Browse latest Browse all 22002

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>