I've been setting up a project which have several libraries which contain 
protobuf generated source code.
I was using the last stable Protobuf version (from sources) but tried few 
hours ago with the last trunk version, with the same exact result (but with 
compilation errors fixed, thumbs up guys)

Basically, I have this configuration:

libprotobuf <- myprotolib <- myexecutable

Here <- means "link with". More details:
 - libprotobuf is in static linking, as default when using visual studio 
projects (I tried dynamic too but there is too much problems, as evoked in 
the readme);
 - myprotolib is in static linking, contain code generated with protoc
 - myexecutable is an executable

I'm using Visual Studio 2012 and CMake 2.8.9 to generate myprotolib and 
myexecutable.
The CMake script will execute a .bat file if on Windows, that will do 
exactly this:

>
> copy protobuf\vsprojects\protobuf.sln protobuf\vsprojects\protobuf_vc11.sln
> call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
> devenv protobuf/vsprojects/protobuf_vc11.sln /upgrade
> devenv protobuf/vsprojects/protobuf_vc11.sln /project libprotobuf /build 
> Debug
> devenv protobuf/vsprojects/protobuf_vc11.sln /project protoc /build Debug
> devenv protobuf/vsprojects/protobuf_vc11.sln /project libprotobuf /build 
> Release
> devenv protobuf/vsprojects/protobuf_vc11.sln /project protoc /build Release


This script will just convert the visual studio project files to VS 2012 
project files, without overwriting the solution file (allowing me to just 
delete my 
protobuf copy and copy paste the last version in the directory and execute 
this script and it's updated).

So far, I didn't have any problem because I was working only inside 
myprotolib, to add some coding facilities related to the message types.
However, at the moment I linked myexecutable to myprotolib, I got this kind 
of errors:

3>libprotobuf.lib(common.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(common.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(message_lite.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(message_lite.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(descriptor.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(descriptor.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(message.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(message.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(unknown_field_set.obj) : error LNK2038: mismatch 
> detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in 
> main.obj
> 3>libprotobuf.lib(unknown_field_set.obj) : error LNK2038: mismatch 
> detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match 
> value 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(generated_message_reflection.obj) : error LNK2038: 
> mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match 
> value '2' in main.obj
> 3>libprotobuf.lib(generated_message_reflection.obj) : error LNK2038: 
> mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't 
> match value 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(once.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(once.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(coded_stream.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(coded_stream.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(wire_format_lite.obj) : error LNK2038: mismatch detected 
> for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(wire_format_lite.obj) : error LNK2038: mismatch detected 
> for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(reflection_ops.obj) : error LNK2038: mismatch detected 
> for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(reflection_ops.obj) : error LNK2038: mismatch detected 
> for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(wire_format.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(wire_format.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(generated_message_util.obj) : error LNK2038: mismatch 
> detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in 
> main.obj
> 3>libprotobuf.lib(generated_message_util.obj) : error LNK2038: mismatch 
> detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match 
> value 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(repeated_field.obj) : error LNK2038: mismatch detected 
> for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(repeated_field.obj) : error LNK2038: mismatch detected 
> for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(zero_copy_stream_impl_lite.obj) : error LNK2038: 
> mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match 
> value '2' in main.obj
> 3>libprotobuf.lib(zero_copy_stream_impl_lite.obj) : error LNK2038: 
> mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't 
> match value 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(descriptor_database.obj) : error LNK2038: mismatch 
> detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in 
> main.obj
> 3>libprotobuf.lib(descriptor_database.obj) : error LNK2038: mismatch 
> detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match 
> value 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(descriptor.pb.obj) : error LNK2038: mismatch detected 
> for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(descriptor.pb.obj) : error LNK2038: mismatch detected 
> for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(dynamic_message.obj) : error LNK2038: mismatch detected 
> for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(dynamic_message.obj) : error LNK2038: mismatch detected 
> for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(text_format.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(text_format.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(tokenizer.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(tokenizer.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(strutil.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(strutil.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(substitute.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(substitute.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(zero_copy_stream_impl.obj) : error LNK2038: mismatch 
> detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in 
> main.obj
> 3>libprotobuf.lib(zero_copy_stream_impl.obj) : error LNK2038: mismatch 
> detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match 
> value 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(extension_set_heavy.obj) : error LNK2038: mismatch 
> detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in 
> main.obj
> 3>libprotobuf.lib(extension_set_heavy.obj) : error LNK2038: mismatch 
> detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match 
> value 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(extension_set.obj) : error LNK2038: mismatch detected 
> for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(extension_set.obj) : error LNK2038: mismatch detected 
> for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(atomicops_internals_x86_msvc.obj) : error LNK2038: 
> mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match 
> value '2' in main.obj
> 3>libprotobuf.lib(atomicops_internals_x86_msvc.obj) : error LNK2038: 
> mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't 
> match value 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(structurally_valid.obj) : error LNK2038: mismatch 
> detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in 
> main.obj
> 3>libprotobuf.lib(structurally_valid.obj) : error LNK2038: mismatch 
> detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match 
> value 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(zero_copy_stream.obj) : error LNK2038: mismatch detected 
> for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(zero_copy_stream.obj) : error LNK2038: mismatch detected 
> for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>libprotobuf.lib(stringprintf.obj) : error LNK2038: mismatch detected for 
> '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
> 3>libprotobuf.lib(stringprintf.obj) : error LNK2038: mismatch detected for 
> 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 
> 'MDd_DynamicDebug' in main.obj
> 3>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other 
> libs; use /NODEFAULTLIB:library
>

All of these errors are apparently because of mismatching configurations 
between libprotobuf and the two other projects.
They are generated only when compiling the exectuable, and only in Debug 
mode. 
Online searches indicates that some part of the libprotobuf configuration 
is set in a way that makes the linker detect it to be compiled in Release 
mode instead of Debug.
See: http://stackoverflow.com/questions/4061929/help-with-linker-error-lnk2038 
for example.

The source of the problem is in the project file configuration BUT.... 
I checked the libprotobuf project properties and I see nothing wrong (I'm 
no expert though).
In particular, I checked the compilation flags used and, as suggested in 
the link, I was looking for /MDd , in Debug mode. It is set correctly 
apparently.

So I'm having a hard time understanding what other libprotobuf project file 
properties are causing this problem. 

Any idea?

Joel Lamotte

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/protobuf/-/npSTyDuAL4UJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to