[CXX-891] CMake 3.5 GUI fails to find libbson when configuring for VS2015 on Win 7 Created: 11/Apr/16  Updated: 11/Apr/16  Resolved: 11/Apr/16

Status: Closed
Project: C++ Driver
Component/s: BSON, Build
Affects Version/s: 3.0.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Steve Hickman Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CDRIVER-1197 CMake instructions for Windows out of... Closed

 Description   

Attempting to use CMake to build new based on instructions found here: https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-(New-Driver)

Was able to build libbson from mongo C driver version 1.3.5, but not mongo C driver (see separate bug report on on that).

When attempting to configure for VS2015, I wasn't sure what LIBBSON_DIR was supposed to be set to. I set it to the root directory where I had installed libbson, then the directory where the lib file was - neither appeared to work. In both cases, I got the following:

No build type selected, default is Release
Checking for module 'libbson-1.0>=1.3.4'

CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindPkgConfig.cmake:363 (message):
A required package was not found
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindPkgConfig.cmake:528 (_pkg_check_modules_internal)
cmake/FindLibBSON.cmake:26 (pkg_check_modules)
src/bsoncxx/CMakeLists.txt:67 (find_package)

Configuring incomplete, errors occurred!
See also "D:/GITRepos/mongo-cxx-driver/build/CMakeFiles/CMakeOutput.log".



 Comments   
Comment by Andrew Morrow (Inactive) [ 11/Apr/16 ]

sxhickman - Would you mind opening a new ticket about the debug build failing?

Comment by Steve Hickman [ 11/Apr/16 ]

One final comment: Release builds for cxx driver all appear to have built cleanly. Debug builds had a few link errors in some of the examples. Specifically, after adding these steps to the end of steps listed in appveyor.yml

  • cmd: msbuild.exe ALL_BUILD.vcxproj /p:Configuration=Debug
  • cmd: msbuild.exe INSTALL.vcxproj /p:Configuration=Debug
  • cmd: msbuild.exe examples\examples.vcxproj /p:Configuration=Debug

I got link errors in some (not all) of the examples. Here are some examples:
Link:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:QUEUE /OUT:"D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\Debug\view_and_value.exe" /INCREMENTAL /NOLOGO /LIBPATH:"D
:/GITRepos/mongo-cxx-driver/install/lib" /LIBPATH:"D:/GITRepos/mongo-cxx-driver/install/lib/Debug" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg3
2.lib advapi32.lib ..\..\src\bsoncxx\Debug\bsoncxx.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"D:/GITRepos/mongo-cxx-driver/examples/bsoncxx/Debug/v
iew_and_value.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:/GITRepos/mongo-cxx-driver/examples/bsoncxx/Debug/view_and_value.lib" /MACHINE:X86 /SAFESEH /machine:X86 view_and_v
alue.dir\Debug\view_and_value.obj
view_and_value.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall bsoncxx::v_noabi::builder::basic::sub_array::sub_array(class bsoncxx::v_noabi::builder::core *
)" (_imp??0sub_array@basic@builder@v_noabi@bsoncxx@@QAE@PAVcore@234@@Z) referenced in function "void __vectorcall bsoncxx::v_noabi::builder::basic::impl::generic_append<class <lambda_c8016f0f43fec5
746f6c2b9c70eb508a> >(class bsoncxx::v_noabi::builder::core *,class <lambda_c8016f0f43fec5746f6c2b9c70eb508a> &&)" (??$generic_append@V<lambda_c8016f0f43fec5746f6c2b9c70eb508a>@@@impl@basic@builder@v
_noabi@bsoncxx@@YQXPAVcore@234@$$QAV<lambda_c8016f0f43fec5746f6c2b9c70eb508a>@@@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj]
view_and_value.obj : error LNK2019: unresolved external symbol "_declspec(dllimport) public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_array::append(void)" (imp?append@sub_array@basic
@builder@v_noabi@bsoncxx@@QAEXXZ) referenced in function "public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_array::append<char const (&)[8]>(char const (&)[8])" (??$append@AAY07$$CBD$$V@s
ub_array@basic@builder@v_noabi@bsoncxx@@QAEXAAY07$$CBD@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj]
view_and_value.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall bsoncxx::v_noabi::builder::basic::sub_document::sub_document(class bsoncxx::v_noabi::builder::
core *)" (_imp??0sub_document@basic@builder@v_noabi@bsoncxx@@QAE@PAVcore@234@@Z) referenced in function "public: __thiscall bsoncxx::v_noabi::builder::basic::document::document(void)" (??0document@
basic@builder@v_noabi@bsoncxx@@QAE@XZ) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj]
view_and_value.obj : error LNK2019: unresolved external symbol "_declspec(dllimport) public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_document::append(void)" (imp?append@sub_document
@basic@builder@v_noabi@bsoncxx@@QAEXXZ) referenced in function "public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_document::append<class std::tuple<char const (&)[8],class <lambda_c8016f0
f43fec5746f6c2b9c70eb508a> &&> >(class std::tuple<char const (&)[8],class <lambda_c8016f0f43fec5746f6c2b9c70eb508a> &&> &&)" (??$append@V?$tuple@AAY07$$CBD$$QAV<lambda_c8016f0f43fec5746f6c2b9c70eb508
a>@@@std@@$$V@sub_document@basic@builder@v_noabi@bsoncxx@@QAEX$$QAV?$tuple@AAY07$$CBD$$QAV<lambda_c8016f0f43fec5746f6c2b9c70eb508a>@@@std@@@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_
value.vcxproj]
D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\Debug\view_and_value.exe : fatal error LNK1120: 4 unresolved externals [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj]
Done Building Project "D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj" (default targets) – FAILED.

"D:\GITRepos\mongo-cxx-driver\examples\examples.vcxproj" (default target) (1) ->
"D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\builder_basic.vcxproj" (default target) (6) ->
(Link target) ->
builder_basic.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall bsoncxx::v_noabi::builder::basic::sub_array::sub_array(class bsoncxx::v_noabi::builder::core
*)" (_imp??0sub_array@basic@builder@v_noabi@bsoncxx@@QAE@PAVcore@234@@Z) referenced in function "void __vectorcall bsoncxx::v_noabi::builder::basic::impl::generic_append<class <lambda_5827542815269
f79f1f8355b8a8e9e6b> >(class bsoncxx::v_noabi::builder::core *,class <lambda_5827542815269f79f1f8355b8a8e9e6b> &&)" (??$generic_append@V<lambda_5827542815269f79f1f8355b8a8e9e6b>@@@impl@basic@builder@
v_noabi@bsoncxx@@YQXPAVcore@234@$$QAV<lambda_5827542815269f79f1f8355b8a8e9e6b>@@@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\builder_basic.vcxproj]
builder_basic.obj : error LNK2019: unresolved external symbol "_declspec(dllimport) public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_array::append(void)" (imp?append@sub_array@basi
c@builder@v_noabi@bsoncxx@@QAEXXZ) referenced in function "public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_array::append<char const (&)[6]>(char const (&)[6])" (??$append@AAY05$$CBD$$V@
sub_array@basic@builder@v_noabi@bsoncxx@@QAEXAAY05$$CBD@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\builder_basic.vcxproj]
builder_basic.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall bsoncxx::v_noabi::builder::basic::sub_document::sub_document(class bsoncxx::v_noabi::builder:
:core *)" (_imp??0sub_document@basic@builder@v_noabi@bsoncxx@@QAE@PAVcore@234@@Z) referenced in function "void __vectorcall bsoncxx::v_noabi::builder::basic::impl::generic_append<class <lambda_26fe
b9ef0b7daaa6792f9543bbb2a482> >(class bsoncxx::v_noabi::builder::core *,class <lambda_26feb9ef0b7daaa6792f9543bbb2a482> &&)" (??$generic_append@V<lambda_26feb9ef0b7daaa6792f9543bbb2a482>@@@impl@basic
@builder@v_noabi@bsoncxx@@YQXPAVcore@234@$$QAV<lambda_26feb9ef0b7daaa6792f9543bbb2a482>@@@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\builder_basic.vcxproj]
builder_basic.obj : error LNK2019: unresolved external symbol "_declspec(dllimport) public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_document::append(void)" (imp?append@sub_documen
t@basic@builder@v_noabi@bsoncxx@@QAEXXZ) referenced in function "public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_document::append<class std::tuple<char const (&)[4],struct bsoncxx::v_no
abi::types::b_bool &&> >(class std::tuple<char const (&)[4],struct bsoncxx::v_noabi::types::b_bool &&> &&)" (??$append@V?$tuple@AAY03$$CBD$$QAUb_bool@types@v_noabi@bsoncxx@@@std@@$$V@sub_document@bas
ic@builder@v_noabi@bsoncxx@@QAEX$$QAV?$tuple@AAY03$$CBD$$QAUb_bool@types@v_noabi@bsoncxx@@@std@@@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\builder_basic.vcxproj]
D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\Debug\builder_basic.exe : fatal error LNK1120: 4 unresolved externals [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\builder_basic.vcxproj]

... and ...

"D:\GITRepos\mongo-cxx-driver\examples\examples.vcxproj" (default target) (1) ->
"D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj" (default target) (19) ->
view_and_value.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall bsoncxx::v_noabi::builder::basic::sub_array::sub_array(class bsoncxx::v_noabi::builder::core
*)" (_imp??0sub_array@basic@builder@v_noabi@bsoncxx@@QAE@PAVcore@234@@Z) referenced in function "void __vectorcall bsoncxx::v_noabi::builder::basic::impl::generic_append<class <lambda_c8016f0f43fe
c5746f6c2b9c70eb508a> >(class bsoncxx::v_noabi::builder::core *,class <lambda_c8016f0f43fec5746f6c2b9c70eb508a> &&)" (??$generic_append@V<lambda_c8016f0f43fec5746f6c2b9c70eb508a>@@@impl@basic@builder
@v_noabi@bsoncxx@@YQXPAVcore@234@$$QAV<lambda_c8016f0f43fec5746f6c2b9c70eb508a>@@@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj]
view_and_value.obj : error LNK2019: unresolved external symbol "_declspec(dllimport) public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_array::append(void)" (imp?append@sub_array@bas
ic@builder@v_noabi@bsoncxx@@QAEXXZ) referenced in function "public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_array::append<char const (&)[8]>(char const (&)[8])" (??$append@AAY07$$CBD$$V
@sub_array@basic@builder@v_noabi@bsoncxx@@QAEXAAY07$$CBD@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj]
view_and_value.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall bsoncxx::v_noabi::builder::basic::sub_document::sub_document(class bsoncxx::v_noabi::builder
::core *)" (_imp??0sub_document@basic@builder@v_noabi@bsoncxx@@QAE@PAVcore@234@@Z) referenced in function "public: __thiscall bsoncxx::v_noabi::builder::basic::document::document(void)" (??0documen
t@basic@builder@v_noabi@bsoncxx@@QAE@XZ) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj]
view_and_value.obj : error LNK2019: unresolved external symbol "_declspec(dllimport) public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_document::append(void)" (imp?append@sub_docume
nt@basic@builder@v_noabi@bsoncxx@@QAEXXZ) referenced in function "public: void __thiscall bsoncxx::v_noabi::builder::basic::sub_document::append<class std::tuple<char const (&)[8],class <lambda_c8016
f0f43fec5746f6c2b9c70eb508a> &&> >(class std::tuple<char const (&)[8],class <lambda_c8016f0f43fec5746f6c2b9c70eb508a> &&> &&)" (??$append@V?$tuple@AAY07$$CBD$$QAV<lambda_c8016f0f43fec5746f6c2b9c70eb5
08a>@@@std@@$$V@sub_document@basic@builder@v_noabi@bsoncxx@@QAEX$$QAV?$tuple@AAY07$$CBD$$QAV<lambda_c8016f0f43fec5746f6c2b9c70eb508a>@@@std@@@Z) [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_an
d_value.vcxproj]
D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\Debug\view_and_value.exe : fatal error LNK1120: 4 unresolved externals [D:\GITRepos\mongo-cxx-driver\examples\bsoncxx\view_and_value.vcxproj]

0 Warning(s)
10 Error(s)

Comment by Andrew Morrow (Inactive) [ 11/Apr/16 ]

Happy to hear that you were able to get it working. Please feel free to re-open this ticket if you still need assistance.

Comment by Steve Hickman [ 11/Apr/16 ]

Your advice about PKG_CONFIG_PATH appears to be the issue. I was able to follow the steps of appveyor.yml and build successfully.

Comment by Andrew Morrow (Inactive) [ 11/Apr/16 ]

You should be setting LIBBSON_DIR to the prefix where you installed the C driver. In other words, if you do the following to build libbson:

cmake.exe -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=c:\x\y\z

Then you should build the C++11 driver like:

cmake.exe -G "Visual Studio 14 2015 Win64" -DLIBBSON_DIR=c:\x\y\z

You can see where we do this in our appveyor configuration: https://github.com/mongodb/mongo-cxx-driver/blob/master/appveyor.yml

What is odd about the error that you are getting is that it appears to originate from pkg_config, which is not standard on Windows. If pkg_config is available on your system, then LIBBSON_DIR has no effect. Perhaps you just need to set PKG_CONFIG_PATH as documented in the quick start guide?

Generated at Wed Feb 07 22:00:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.