building with CMake on Windows & VS2010 SP1

88 views
Skip to first unread message

John C.

unread,
Nov 16, 2011, 1:52:33 PM11/16/11
to libphonenumber-discuss
Hello everyone,

So I've taken it upon myself with what time I have to get the CMake
build working with Windows since I would like the testing app, but I'm
having an issue with CMake namely using CMake-gui.

I've downloaded the latest boost 1.48 (released today), and unzipped
the source folder to my code directory. I've run bootstrap.bat and
then "bjam release debug -j4" to build boost. Now opening CMake-gui
for libphonenumber asks for "Boost_DIR" so I point it to the boost
folder I've unzipped it to. Clicking configure every time now it says
in the CMake output:

Could NOT find Boost
CMake Error at CMakeLists.txt:27 (message):
Can't find Boost Thread: can't locate Boost. Please read the
README.
Call Stack (most recent call first):
CMakeLists.txt:78 (print_error)

This is on my home computer, but I'm fairly certain I had this working
at my office workstation so I'm not sure what exactly is going wrong
here... Can anyone help me debug the CMake process here?

/John

John C.

unread,
Nov 16, 2011, 2:47:32 PM11/16/11
to libphonenumber-discuss
Ah.. so this may have to do with cmake not knowing these latest
versions of boost... i'll try 1.43 from my codebase at work and brb.

John C.

unread,
Nov 16, 2011, 4:18:04 PM11/16/11
to libphonenumber-discuss
nope. that didn't seem to work either. very mystified...

Philippe Liard

unread,
Nov 17, 2011, 3:18:13 AM11/17/11
to libphonenum...@googlegroups.com
Hi John,

I started yesterday installing Windows to build/test the library. I will help you once everything is working.

Cheers,
Philippe.

--
Philippe Liard

Philippe Liard

unread,
Nov 21, 2011, 7:59:29 AM11/21/11
to libphonenum...@googlegroups.com
Hi John,

I also had the problems you mentioned. I found a workaround using a binary distribution available at:
http://www.boostpro.com/download/

I downloaded the BoostPro 1.44.0 installer and only selected Boost thread during the installation process.
It works perfectly.

I now have to build/install the other dependencies.


Cheers,
Philippe.

--
Philippe Liard


John C.

unread,
Nov 22, 2011, 2:33:48 AM11/22/11
to libphonenumber-discuss
I tried the BoostPro 1.44.0 installer and it seems to work for me too.
I got the gtest lib to build using the included msvc projects, but
they required upgrading to VS2010. Now currently working on protobuf
building.

/John

On Nov 21, 4:59 am, Philippe Liard <philip.li...@gmail.com> wrote:
> Hi John,
>
> I also had the problems you mentioned. I found a workaround using a binary
> distribution available at:http://www.boostpro.com/download/
>
> I downloaded the BoostPro 1.44.0 installer and only selected Boost thread
> during the installation process.
> It works perfectly.
>
> I now have to build/install the other dependencies.
>
> Cheers,
> Philippe.
>
> --
> Philippe Liard
>

> On Thu, Nov 17, 2011 at 09:18, Philippe Liard <philip.li...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hi John,
>
> > I started yesterday installing Windows to build/test the library. I will
> > help you once everything is working.
>
> > Cheers,
> > Philippe.
>
> > --
> > Philippe Liard
>

John C.

unread,
Nov 23, 2011, 3:16:50 AM11/23/11
to libphonenumber-discuss
So for best results with gtest and libprotobuf, checkout the latest
protobuf code from their SVN repository. Included with protobuf is a
gtest folder that also builds well with VS2010. Both protobuf and
gtest projects included require upgrading to VS2010 but both will
build completely without error.

Plugging these into cmake for libphonenumber with ICU 4.8.1
successfully generates a VS2010 project.

At this point default_logger.h requires patching for windows to fix
the std::snprintf that doesn't exist in windows c++ land. Here's the
patch I used:

Index: default_logger.h
===================================================================
--- default_logger.h (revision 389)
+++ default_logger.h (working copy)
@@ -17,6 +17,10 @@
#ifndef I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
#define I18N_PHONENUMBERS_DEFAULT_LOGGER_H_

+#if _MSC_VER
+#define snprintf _snprintf_s
+#endif
+
#ifdef USE_GOOGLE_BASE

namespace i18n {
@@ -67,7 +71,7 @@
struct ConvertToString<int> {
static inline string DoWork(const int& n) {
char buffer[16];
- std::snprintf(buffer, sizeof(buffer), "%d", n);
+ snprintf(buffer, sizeof(buffer), "%d", n);
return string(buffer);
}
};


Building this project succeeds in building a phonenumber.lib and
phonenumber_test.lib but the phonenumber-shared DLL fails to build as
well as the test app.

Philippe Liard

unread,
Nov 23, 2011, 3:43:54 AM11/23/11
to libphonenum...@googlegroups.com
Hi John,

Thanks for your help!

I also encountered the same problem with default_logger.h. We have a patch being reviewed that will be committed soon.

I will also commit a small patch fixing the CMakeLists to make it require boost datetime and link with the static libraries on Windows.

You said that the phonenumber shared library and the tests failed to build? Is that related to linkage errors?
The CMakeLists patch should fix the first issue.
If you encounter linkage errors with GTest such as multiple defined symbols, I fixed that using the gtest-md lib instead of gtest (see the Visual Studio projects in gtest).

Everything builds fine on my side but one unit test fails with Chinese characters. I will try to fix that and write some instructions.

Thanks,
Philippe.

--
Philippe Liard

John C.

unread,
Nov 23, 2011, 12:37:20 PM11/23/11
to libphonenumber-discuss
Hi Philippe,

That's great news! Yes, I was getting linkage errors last night. I
look forward to your patches then!

/John

On Nov 23, 12:43 am, Philippe Liard <philip.li...@gmail.com> wrote:
> Hi John,
>

John C.

unread,
Nov 24, 2011, 12:55:54 AM11/24/11
to libphonenumber-discuss
Hi Phillippe,

What version of gtest are you using? The one included with protobuf
2.4.1 doesn't build the gtest-md lib.

/John

John C.

unread,
Nov 24, 2011, 1:21:08 AM11/24/11
to libphonenumber-discuss
Nevermind.. found the separate solution for gtest-md.

It builds for me! In the debug build I had to change some linker
settings to point to the debug gtestd.lib, and even then running the
debug libphonenumber_test.exe crashed. The release build however ran
fine with one error. I'm not sure if it's the same one you got, but it
was:
[ FAILED ] PhoneNumberMatcherTest.IsLatinLetter

Thanks for the updates, glad we got windows finally working with
cmake!

Philippe Liard

unread,
Nov 24, 2011, 3:37:02 AM11/24/11
to libphonenum...@googlegroups.com
Hi John,

I am glad that you finally have the library working on Windows!
We have exactly the same failing test. I will try to fix that.


Cheers,
Philippe.

--
Philippe Liard


On Thu, Nov 24, 2011 at 07:21, John C. <jpch...@gmail.com> wrote:
It builds for me!

Reply all
Reply to author
Forward
0 new messages