As the title states I cannot get protobuf to link successfully.
Here is the small test program. note the AddressBook
class was generated usin gthe protoc compiler that was built when i compiled protobuf.Additionally, this proto file is part of googles protobuf examples that is included with the source.
#define PROTOBUF_USE_DLLS #include <iostream> #include "addressbook.pb.h" #pragma comment(lib, "libprotocd.lib") #pragma comment(lib, "libprotobufd.lib") #pragma comment(lib, "libprotobuf-lited.lib") int main(int argc, const char* argv[]) { tutorial::AddressBook ab; return 0; }
Here are the errors I am receiving.
LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const * const google::protobuf::internal::empty_string_" (?empty_string_@internal@protobuf@google@@3PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@EB) LNK2001: unresolved external symbol "__int64 google::protobuf::internal::empty_string_once_init_" (?empty_string_once_init_@internal@protobuf@google@@3_JA)
Some assertions:
- Same code running on linux.. With the exception of -lprotoc -lprotobuf -lprotobuf-lite vs. the #pregma stuff
- Happens both in VS2013 and VS2015
- Tried both 3.0-Release and latest code from git. Same issue.
- I have tried this with both the
debug
target as well as therelease
(when using release removed trailingd
from library name) target - Made sure that both the additional
include
andlibrary
directories were set in the VS project.linker --> General --> Additional Library Directories
is set to the place where the compiled .dll are located`
At this point I pretty much turned my attention to google to see what I could find. I ran across the following.
- 2015 not fully supported. It was old, but figured I would try vs2013
- protobuf dynamic linking Yes. When building with cmake I enabled shared library support and have the #define in my program
- disable inline expansion
Still, not able to progress past the above errors. Any help is greatly appreciated.