Building couchbase-lite-core on Windows


#1

Hi,

I’m trying to build couchbase-lite-core on Windows. I’m following the README instructions.

What I did:

cd build_cmake
cmake -G "Visual Studio 14 2015 Win64"
msbuild  LiteCore.sln /p:Configuration=RelWithDebInfo /t:LiteCore

It compiles for a long time but it ends in error:

Build FAILED.
"C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCore.sln" (LiteCore target) (1) ->
"C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCore.vcxproj.metaproj" (default target) (2) ->
"C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCoreStatic.vcxproj.metaproj" (default target) (10) ->
"C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCoreStatic.vcxproj" (default target) (11) -> (ClCompile target) -> C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\LiteCore\Query\QueryParser.cc(285): warning C4267: '+=': conversion from 'size_t' to 'unsigned int', possible loss of data [C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCoreStatic.vcxproj]
"C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCore.sln" (LiteCore target) (1) ->
"C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCore.vcxproj.metaproj" (default target) (2) -> "C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCoreStatic.vcxproj.metaproj" (default target) (10) ->
"C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCoreStatic.vcxproj" (default target) (11) -> (ClCompile target) -> C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\C\c4Base.cc(29): fatal error C1083: Cannot open include file: 'repo_version.h': No such file or directory [C:\Users\nsantos\workspace\couchbase_qt\couchbase-lite-core\build_cmake\LiteCoreStatic.vcxproj]

1 Warning(s)
1 Error(s)

Time Elapsed 00:00:06.29

In summary, it seems that the fact it can’t find repo_version.h is a problem:

Cannot open include file: 'repo_version.h'

It seems that repo_version.h is dynamicly generated. By who?

Can I workaround this issue manually?

Thanks in advance!

Regards,

Nuno


#2

repo_version.h is generated during the CMake build.

CMake runs the powershell script $ROOT/build_cmake/scripts/get_repo_version.ps1 to create it.


#3

Your cmake call is missing the final argument (the location of the CMakeList.txt file) which could also be affecting things.


#4

@borrrden the missing was a typo of mine.

In the mean time I have found a couple of things…

I was executing the cmake in a normal command prompt. I have tried in a powershell but there was a similar result. The script get_repo_version.ps1 couldn’t be executed due to security restrictions. I had to call:

 Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope
CurrentUser

In order to be able to call that script. Then I have tried to run the msbuild in the same powershell but no joy.

I have opened the regular command prompt and it has build successfully.

I think you should add this step to the README file. Cmake should be run on a powershell after setting an unrestricted execution policy.


#5

Now I’m stumbling with linking errors, hundreds of them:

LiteCoreStatic.lib(c4Base.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
LiteCoreStatic.lib(c4Base.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MTd_StaticDebug' in main.obj
LiteCoreStatic.lib(c4Database.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
LiteCoreStatic.lib(c4Database.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MTd_StaticDebug' in main.obj
LiteCoreStatic.lib(c4Document.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
LiteCoreStatic.lib(c4Document.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MTd_StaticDebug' in main.obj
LiteCoreStatic.lib(c4DocEnumerator.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
LiteCoreStatic.lib(c4DocEnumerator.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MTd_StaticDebug' in main.obj
LiteCoreStatic.lib(c4Observer.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
...

I’m googling around to find a solution. If you have any suggestion, I’m all hears!

Thanks!


#6

You need to compile all of your components with the same c++ runtime library variant. This kind of thing happens when you mix default debug and release builds for example since one will link with the debug runtime and the other with the release runtime.


#7

@borrrden I have changed all the targets to link Runtime Library /MT and it is now working with my build kit.

Great success! :wink: