链接protobuf-lite错误:错误LNK2038:检测到'_ITERATOR_DEBUG_LEVEL'不匹配:值'2'与值'0'不匹配

时间:2016-05-01 11:04:59

标签: c++ visual-studio protocol-buffers

这是我的protobuf模板文件, test.proto

package HProtocol;

option optimize_for = LITE_RUNTIME;

message add {
    required int32  val = 1;
}

这个生成代码的命令:

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

这是我的c ++代码, 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;
}

我在版本x64中构建它,如果链接 libprotobuf.lib ,构建就可以了,只是一些警告,但如果使用 libprotobuf-lite.lib 进行构建,那么很多发生了错误:

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

我只想使用protobuf-lite,而不是protobuf,所以我该如何解决这个问题呢? 我使用VS2015企业版更新2。

0 个答案:

没有答案