I'm building a c++ project with soci using this line of code:
session sql(odbc, "DRIVER={SQL Server};SERVER=server;DATABASE=database;UID=user;PWD=pass;");
I get this linker error message:
Error 1 error LNK2019: unresolved external symbol
"public: __cdecl soci::session::session(class soci::backend_factory const
&,class std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const &)" (??
0session@soci@@QEAA@AEBVbackend_factory@1@AEBV?$basic_string@DU
$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function main
D:\Development\Private\K\kserver\kserver\main.obj kserver
I have built soci using:
cmake -G "Visual Studio 12 Win64" -DWITH_BOOST=ON -DWITH_ODBC=ON -DCMAKE_BUILD_TYPE=Debug ..\soci-master\src
I have also added the include folders to the project and that seems to be fine.
I've also added:
D:\Development\Tools\lib\soci\lib\Debug
to the linker directories.
It works if I build with only:
session sql()
It seems like I'm missing the ODBC backend library. Where do I find that?
The answer was this (no hair left):
I'm generating the solution using cmake with this:
"Visual Studio 12 Win64"
That means that I'm creting a Studio 12 2013 solution.
I have previously installed Studio 11 2012 which had installed the x64 Cross Tools Command Prompt
.
It seems like Studio 2013 Community Edition which I'm testing to build with doesn't install the shortcuts to the Studio 2013 environment.
Following this when building SOCI the backend for ODBC wasn't built since it couldn't find the include and library folders which I didn't notice in the output of the build.
To fix this I needed to start the command line using:
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"" x86_amd64
After that the ODBC project was also created in the solution and the project could be built.