0

this's my protobuf template file, test.proto:

package HProtocol;

option optimize_for = LITE_RUNTIME;

message add {
    required int32  val = 1;
}

this's command that generate code:

protoc.exe --proto_path=custom_msg --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:build/src custom_msg/test.proto

this's my c++ code, app.cpp:

#pragma once 

//#pragma comment(lib,"libprotobuf.lib") 
#pragma comment(lib,"libprotobuf-lite.lib") 

#include <google/protobuf/message_lite.h>
#include "test.pb.h"

int main(char** args, int size)
{
    HProtocol::add a;
    return 1;
}

I build it in Release x64, if link libprotobuf.lib, building will be ok, just some warnings, but if building with libprotobuf-lite.lib, lots of errors occurred:

1>libprotobuf-lite.lib(common.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in App.obj
1>libprotobuf-lite.lib(common.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in App.obj
1>libprotobuf-lite.lib(message_lite.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in App.obj
1>libprotobuf-lite.lib(message_lite.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in App.obj
1>libprotobuf-lite.lib(coded_stream.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in App.obj
1>libprotobuf-lite.lib(coded_stream.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in App.obj
1>libprotobuf-lite.lib(wire_format_lite.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in App.obj
1>libprotobuf-lite.lib(wire_format_lite.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in App.obj
1>libprotobuf-lite.lib(zero_copy_stream_impl_lite.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in App.obj
1>libprotobuf-lite.lib(zero_copy_stream_impl_lite.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in App.obj
1>libprotobuf-lite.lib(once.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in App.obj
1>libprotobuf-lite.lib(once.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in App.obj
1>libprotobuf-lite.lib(zero_copy_stream.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in App.obj
1>libprotobuf-lite.lib(zero_copy_stream.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in App.obj
1>libprotobuf-lite.lib(atomicops_internals_x86_msvc.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in App.obj
1>libprotobuf-lite.lib(atomicops_internals_x86_msvc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in App.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libprotobuf-lite.lib(zero_copy_stream_impl_lite.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
1>libprotobuf-lite.lib(common.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
1>libprotobuf-lite.lib(message_lite.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
1>libprotobuf-lite.lib(coded_stream.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
1>libprotobuf-lite.lib(wire_format_lite.obj) : error LNK2001: unresolved external symbol __imp__invalid_parameter
1>libprotobuf-lite.lib(zero_copy_stream_impl_lite.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReportW
1>libprotobuf-lite.lib(common.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReportW
1>libprotobuf-lite.lib(message_lite.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReportW
1>libprotobuf-lite.lib(coded_stream.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReportW
1>libprotobuf-lite.lib(wire_format_lite.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReportW

I just want to use protobuf-lite, not protobuf, so how can I resolve this? I use VS2015 Enterprise Edition update 2.

Protoss
  • 512
  • 7
  • 27

0 Answers0