我试图构建Mongo C++11驱动程序,以便在我的项目中使用。蒙古族的司机们编译得很好。关于如何使用它们的说明坚持认为,在为自己的项目使用时,下面的代码也应该是我的项目的.vcxproj的一部分(如果使用Visual,我在Windows 10 64位上这样做)。
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>c:\local\boost_1_59_0\;C:\mongo-cxx-driver\include\mongocxx\v_noabi;C:\mongo-cxx-driver\include\bsoncxx\v_noabi;C:\mongo-c-driver\include\libmongoc-1.0;C:\mongo-c-driver\include\libbson-1.0;$(IncludePath)</IncludePath>
<LibraryPath>c:\mongo-c-driver\lib\;c:\mongo-cxx-driver\lib\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>MONGOCXX_STATIC;BSONCXX_STATIC;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libmongocxx.lib;libbsoncxx.lib;mongoc-static-1.0.lib;bson-1.0.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>我需要什么样的代码来确保这段代码自动包含在由.vcxproj生成的CMake中?我的CMakeLists.txt如下所示。
# CMakeLists.txt
# Building the test project
cmake_minimum_required(VERSION 3.7)
project(testing)
set(APP_SOURCES
test.cpp
)
link_directories(../../installed_mongocxx/lib)
add_executable(testapp ${APP_SOURCES})
target_link_libraries(testapp mongocxx bsoncxx)
target_include_directories(testapp PUBLIC
../../installed_mongocxx/include/mongocxx/v_noabi
../../installed_mongocxx/include/bsoncxx/v_noabi
E:/Software/Libraries/Boost/boost_1_64_0
)
install(TARGETS testapp
DESTINATION bin)发布于 2017-11-02 07:03:46
使用vcpkg如何?这是编译库/驱动程序的一种简单方法。
按照git上提到的说明下载vcpkg。https://github.com/Microsoft/vcpkg
步骤1 C:\vcpkg>.\vcpkg search mongodb
你会看到这样的事情
用C语言为MongoDB编写的客户端库.
MongoDB驱动器3.1.1-1 MongoDB C++驱动程序。
步骤2 C:\vcpkg搜索mongodb安装mongo-cxx-驱动程序
那就喝杯咖啡..。
Stap 3
C:\vcpkg>.\vcpkg集成安装
完成了..。
备注先决条件:
Windows 10、8.1或7
2017或2015更新3
然后简单地创建一个项目并在项目中添加所需的包含。
答复:@JoyoWaseem
https://stackoverflow.com/questions/44737859
复制相似问题