我還沒有完成C驅動程序,但我正在使用Qt Creator進行C++編程。您需要在您的項目中包含boost庫,並且 - 對於我下載的MongoDB客戶端C++版本 - 它們需要成爲Boost 1.49庫,不多也不少。下載它,只是讓它建立所有的庫,即使你只需要其中四個。以下是我Qt Creator .pro文件中的相關代碼,並且請注意,我的C:/ MongoDB文件夾中的所有內容都是從MongoDB源下載的,或者至少由直接下載的scons構建。
INCLUDEPATH += C:/MongoDB/src \
C:/MongoDB/src/mongo/client \
C:/MongoDB/src/third_party/boost \
C:/MongoDB/src/third_party/boost/boost \
C:/MongoDB/src/mongo \
C:/MongoDB/src/third_party/boost/boost/algorithm \
C:/MongoDB/src/third_party/boost/boost/asio \
C:/MongoDB/src/third_party/boost/boost/bind \
C:/MongoDB/src/third_party/boost/boost/concept \
C:/MongoDB/src/third_party/boost/boost/config \
C:/MongoDB/src/third_party/boost/boost/container \
C:/MongoDB/src/third_party/boost/boost/date_time \
C:/MongoDB/src/third_party/boost/boost/detail \
C:/MongoDB/src/third_party/boost/boost/exception \
C:/MongoDB/src/third_party/boost/boost/filesystem \
C:/MongoDB/src/third_party/boost/boost/function \
C:/MongoDB/src/third_party/boost/boost/functional \
C:/MongoDB/src/third_party/boost/boost/integer \
C:/MongoDB/src/third_party/boost/boost/io \
C:/MongoDB/src/third_party/boost/boost/iterator \
C:/MongoDB/src/third_party/boost/boost/math \
C:/MongoDB/src/third_party/boost/boost/move \
C:/MongoDB/src/third_party/boost/boost/mpl \
C:/MongoDB/src/third_party/boost/boost/numeric \
C:/MongoDB/src/third_party/boost/boost/optional \
C:/MongoDB/src/third_party/boost/boost/pending \
C:/MongoDB/src/third_party/boost/boost/preprocessor \
C:/MongoDB/src/third_party/boost/boost/program_options\
C:/MongoDB/src/third_party/boost/boost/random \
C:/MongoDB/src/third_party/boost/boost/range \
C:/MongoDB/src/third_party/boost/boost/regex \
C:/MongoDB/src/third_party/boost/boost/smart_ptr \
C:/MongoDB/src/third_party/boost/boost/spirit \
C:/MongoDB/src/third_party/boost/boost/system \
C:/MongoDB/src/third_party/boost/boost/test \
C:/MongoDB/src/third_party/boost/boost/thread \
C:/MongoDB/src/third_party/boost/boost/tuple \
C:/MongoDB/src/third_party/boost/boost/type_traits \
C:/MongoDB/src/third_party/boost/boost/typeof \
C:/MongoDB/src/third_party/boost/boost/units \
C:/MongoDB/src/third_party/boost/boost/unordered \
C:/MongoDB/src/third_party/boost/boost/utility \
DEFINES += _UNICODE \
SYM_STATICLIB
QMAKE_CFLAGS_RELEASE += /MT
QMAKE_CXXFLAGS_RELEASE += /MT
QMAKE_CFLAGS_DEBUG += /MTd
QMAKE_CXXFLAGS_DEBUG += /MTd
LIBS += -L$$PWD/../../../../../../MongoDB/src/third_party -lWS2_32
LIBS += -L$$PWD/../../../../../../MongoDB/src/third_party -lDbgHelp
CONFIG(debug, debug|release) {
LIBS += -LC:\MongoDB\build\win32\debug\client_build -lmongoclient
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/thread/build/msvc-10.0/debug/link-static/runtime-link-static/threading-multi/ -llibboost_thread-vc100-mt-sgd-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/date_time/build/msvc-10.0/debug/link-static/runtime-link-static/threading-multi/ -llibboost_date_time-vc100-mt-sgd-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/system/build/msvc-10.0/debug/link-static/runtime-link-static/ -llibboost_system-vc100-sgd-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/filesystem/build/msvc-10.0/debug/link-static/runtime-link-static/ -llibboost_filesystem-vc100-sgd-1_49
}
CONFIG(release, debug|release) {
LIBS += -LC:\MongoDB\build\win32\release\client_build -lmongoclient
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/thread/build/msvc-10.0/release/link-static/runtime-link-static/threading-multi/ -llibboost_thread-vc100-mt-s-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/date_time/build/msvc-10.0/release/link-static/runtime-link-static/threading-multi/ -llibboost_date_time-vc100-mt-s-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/system/build/msvc-10.0/release/link-static/runtime-link-static/ -llibboost_system-vc100-s-1_49
LIBS += -L$$PWD/../../../../../../Boost/1.49/bin.v2/libs/filesystem/build/msvc-10.0/release/link-static/runtime-link-static/ -llibboost_filesystem-vc100-s-1_49
}
需要注意的是Qt是已知的,當對靜態C++運行時建胡作非爲,所以它可能是最好按照我給出here的意見和其中防靜電運行時生成的非Qt的C++ DLL包裹司機,然後在主要的Qt應用程序中使用該dll,該應用程序將根據動態運行時進行構建。
另外請注意,我必須手動複製winsock並將庫放到根文件夾中,並手動包含它們,因爲Qt Creator不接受「Program Files(x86)」路徑,因爲它有空格。
我意識到這不是一個「Mongo C」的答案,但是你確實提到了你只是使用C驅動程序出於讓C++工作的沮喪,所以我想我會分享我所知道的。