glog 0.3.4 won't link with Ceres 1.11.0 under MSVC2013

1,741 views
Skip to first unread message

Thomas Sharpless

unread,
Apr 18, 2016, 10:48:24 PM4/18/16
to Ceres Solver
One more time, I'm trying to build ceres (1.11.0) on Windows with glog (0.3.4), and getting stonewalled. 

cloned latest glog from github, configured with cmake, built with msvc2013, static libraries, no complaints.  Except that INSTALL fails. So just left the libs where built.

At ceres configure, cmake happily verifies that logging.h is where I said it was, but accepts damn near anything for "GLOG_LIBRARY".  At generate time, if that is a directory, it discards all targets that link against it.  If it is an actual library, say Release/glog.lib, the generated MSVC++ project flags every single reference into it as unresolved at link time.

This is not what I expect in a major s/w distribution.  First of all, on Windows there are always Release and Debug libraries that must be used to link the respective versions of anything.  Glog builds those, but the ceres cmake setup shows no signs of recognizing that both might exist -- it insists on one full library file name, and puts only that name in the generated link commands, debug or release.
Secondly, the static library that glog builds is somehow incompatible with the ceres code built by the same compiler.

Please try it for yourself, and then tell me how you got ceres 1.11.0 to build with glog 0.3.4 using msvc2013.  Or should I be using some older release of glog?  Anyhow, your build instructions and your cmake code both need work.

Sameer Agarwal

unread,
Apr 18, 2016, 11:08:47 PM4/18/16
to Ceres Solver
Thomas,
Thank you for the build report. I am sorry you had trouble getting it to work. Alex is our cmake miester, he will get back to you shortly.

That said, ceres solver is an open source project and none of the core developers use windows as their primary development environment. We depend on bug reports and fixes from users to help maintain it. So, if you would like to help us improve the windows build, we would gladly accept your (or anyone else's) help.

Sameer




--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/f480655a-bd45-4b7c-a111-29531611c715%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Sharpless

unread,
Apr 19, 2016, 12:06:10 AM4/19/16
to Ceres Solver
update: glog (release build)  is now installed in C:\Program Files according to its project specs (I had forgotten to run MSVC as administrator).  Re-configured ceres accordingly & generated new project files.  Same gazillion link errors, e.g.
Error 165 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl google::base::CheckOpMessageBuilder::CheckOpMessageBuilder(char const *)" (__imp_??0CheckOpMessageBuilder@base@google@@QEAA@PEBD@Z) C:\Users\tks\Projects\ceres-solver-1.11.0\build-ceres-solver-msvc2013\examples\ceres.lib(partitioned_matrix_view_2_3_4.obj) curve_fitting_c

Keir Mierle

unread,
Apr 19, 2016, 4:01:04 AM4/19/16
to ceres-...@googlegroups.com
Hi Thomas,

Long ago I did the initial Windows port, but I am not a Windows user in general and haven't tried compiling Ceres on Windows in a long time. In this case, I suspect there may be an issue with glog namespaces. When building glog, there is some ability to control what namespace it uses. If the generated namespace in the headers do not match the compiled namespace (which would be weird, but could happen if there is a configure bug), then link errors like what you are seeing might happen. Another possibility is that somehow the link order is wrong. On Linux and Mac, the link order matters and could trigger errors like the ones above.

You may want to try this wrapper that supposedly simplifies the process of getting Ceres to compile on Windows. Maybe we could convince the author to upstream that effort! There is also this guide, that may be outdated, on getting Ceres to work on Windows. You could also try using miniglog, which we generally don't advise, but might help you move forward.

We would love to have better Windows support, and since you are a Windows user, please consider contributing. We're happy to accept documentation or other patches. Ceres is maintained by volunteers (but passionate ones!); however, there are no full time developers, so your support is much appreciated.

Happy optimizing,
Keir

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.

Johannes Schönberger

unread,
Apr 19, 2016, 4:12:10 AM4/19/16
to ceres-...@googlegroups.com
Hi,

I recently ran into a similar problem. With the latest Glog release, they introduced a CMakeLists.txt. Do not use it on Windows and fall back to the provided Visual Studio projects: https://github.com/google/glog/tree/master/vsprojects - even with modifying the source code by setting GOOGLE_GLOG_DLL_DECL I couldn't get it to work with the CMakeLists.txt.

Hope it helps.

Cheers, Johannes
> To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CADpYijHC_yTVvawEaf%2BMY712BV69DKHK%3DsqW5Sj97EB8pcDpEw%40mail.gmail.com.

Thomas Sharpless

unread,
Apr 19, 2016, 9:40:08 AM4/19/16
to Ceres Solver
Johannes, I built glog with the old msvc projects and get the same errors.
Keir, the ceres cmake configuration process has a number of infelicities, at least on windows, that I would love to fix.  But I don't have time.

HOWEVER it appears that the problem here is in the glog headers, not ceres.  Although I built glog as a static library, under Windows all the glog headers define the external linkage as "__declspec(dllimport)"; there is no check for a static build.  That makes the linker prefix entry point names with "__imp_" and hence not find them in the static lib.

The easy workaround obviously is to build glog as a dll.  That is no great hardship; I have already decided to build ceres as a dll too, so that I can link ceres release code with debug app code.

It would be good if you could put a warning about this on the ceres build instructions page, I'm sure other Windows users would appreciate it.  I will try to file a bug report with the glog team.


On Monday, April 18, 2016 at 10:48:24 PM UTC-4, Thomas Sharpless wrote:

Johannes Schönberger

unread,
Apr 19, 2016, 9:54:09 AM4/19/16
to ceres-...@googlegroups.com
@Thomas, Are you sure you are linking against the static library now? The VS projects install the binaries into a different directory than CMakeLists.txt. I just checked on my machine and it works this way.
> --
> You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/c44a80e9-4936-4d1c-b534-f02afec7dc3e%40googlegroups.com.

Thomas Sharpless

unread,
Apr 19, 2016, 12:07:24 PM4/19/16
to Ceres Solver
Johannes, my problem is that the current glog headers dictate dll linkage, so I can't link against the static library.
I thought I'd just build a glog dll using the old readymade VC projects; but those won't build 64 bit (even if I set that option in MSVC).
So plan C is change the stupid declarations in the glog headers.  Hopefully just modifying logging.h will be enough.

Johannes Schönberger

unread,
Apr 19, 2016, 12:40:51 PM4/19/16
to ceres-...@googlegroups.com
There are special include files for Windows, see include/Windows or sth (on mobile so cannot check right now). 

Thomas Sharpless

unread,
Apr 20, 2016, 11:38:37 AM4/20/16
to Ceres Solver
Yes I am using the windows specific include files.
My final solution was to modify logging.h so that it does NOT call for dll linkage when GLOG_STATIC is defined.  Then build everything with GLOG_STATIC defined.   This solution cannot be applied just by modifying the cmake scripts.

Aditya Gupta

unread,
Apr 28, 2016, 5:08:20 PM4/28/16
to Ceres Solver
Hello Thomas, I am having the exact same issue described in this thread. I guess all windows users would face this issue with the dll and static library. Would you mind sharing your changes to the logging.h file? Also did you also have to change the CMakeLists.txt file as discussed above. Thanks. -Adit

Thomas Sharpless

unread,
Apr 29, 2016, 10:08:40 AM4/29/16
to Ceres Solver
Aditya,

I did not change CMake scripts as I prefer to link glog statically anyhow.
I changed just one copy of logging.h, the one seen by the ceres build, from...
// Annoying stuff for windows -- makes sure clients can import these functions
#ifndef GOOGLE_GLOG_DLL_DECL
# if defined(_WIN32) && !defined(__CYGWIN__)
#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
# else
#   define GOOGLE_GLOG_DLL_DECL
# endif
#endif
To
// Annoying stuff for windows -- makes sure clients can import these functions
/// even if they want to use the static library! -- TKS
#ifndef GOOGLE_GLOG_DLL_DECL
# if defined(_WIN32) && !defined(__CYGWIN__)
#   ifdef GLOG_STATIC
#     define GOOGLE_GLOG_DLL_DECL 
#   else
#     define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
#   endif
# else
#   define GOOGLE_GLOG_DLL_DECL
# endif
#endif

Thomas Sharpless

unread,
Apr 29, 2016, 10:11:08 AM4/29/16
to Ceres Solver
Oh, and of course defined GLOG_STATIC while building Ceres.  

Aditya Gupta

unread,
Apr 29, 2016, 11:39:20 AM4/29/16
to Ceres Solver
Thanks Thomas. The changes you mentioned reduced the errors from some 32k to 24. I previously commented //__declspec(dllimport) in logging.h (similar) and that also brought down the number of errors. But I am not able to clear out these 24 linking errors. The error message says in file glog.lib(logging.obj) and glob.lib(vlog_is_on.obj), called from curve_fitting, helloworld, etc.

Any ideas, how I could resolve these. Appreciate all your help. Thanks.

Error 1 error LNK2019: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) referenced in function "void __cdecl fLS::`dynamic initializer for 'o_alsologtoemail''(void)" (??__Eo_alsologtoemail@fLS@@YAXXZ) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(logging.obj) curve_fitting
Error 2 error LNK2001: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(vlog_is_on.obj) curve_fitting
Error 3 error LNK1120: 1 unresolved externals C:\Users\agupta\Documents\EIS\ceres\ceres-build\bin\Release\curve_fitting.exe curve_fitting
Error 4 error LNK2019: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) referenced in function "void __cdecl fLS::`dynamic initializer for 'o_alsologtoemail''(void)" (??__Eo_alsologtoemail@fLS@@YAXXZ) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(logging.obj) curve_fitting_c
Error 5 error LNK2001: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(vlog_is_on.obj) curve_fitting_c
Error 6 error LNK1120: 1 unresolved externals C:\Users\agupta\Documents\EIS\ceres\ceres-build\bin\Release\curve_fitting_c.exe curve_fitting_c
Error 7 error LNK2019: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) referenced in function "void __cdecl fLS::`dynamic initializer for 'o_alsologtoemail''(void)" (??__Eo_alsologtoemail@fLS@@YAXXZ) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(logging.obj) ellipse_approximation
Error 8 error LNK2001: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(vlog_is_on.obj) ellipse_approximation
Error 9 error LNK1120: 1 unresolved externals C:\Users\agupta\Documents\EIS\ceres\ceres-build\bin\Release\ellipse_approximation.exe ellipse_approximation
Error 10 error LNK2019: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) referenced in function "void __cdecl fLS::`dynamic initializer for 'o_alsologtoemail''(void)" (??__Eo_alsologtoemail@fLS@@YAXXZ) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(logging.obj) helloworld
Error 11 error LNK2001: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(vlog_is_on.obj) helloworld
Error 12 error LNK1120: 1 unresolved externals C:\Users\agupta\Documents\EIS\ceres\ceres-build\bin\Release\helloworld.exe helloworld
Error 13 error LNK2019: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) referenced in function "void __cdecl fLS::`dynamic initializer for 'o_alsologtoemail''(void)" (??__Eo_alsologtoemail@fLS@@YAXXZ) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(logging.obj) helloworld_analytic_diff
Error 14 error LNK2001: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(vlog_is_on.obj) helloworld_analytic_diff
Error 15 error LNK1120: 1 unresolved externals C:\Users\agupta\Documents\EIS\ceres\ceres-build\bin\Release\helloworld_analytic_diff.exe helloworld_analytic_diff
Error 16 error LNK2019: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) referenced in function "void __cdecl fLS::`dynamic initializer for 'o_alsologtoemail''(void)" (??__Eo_alsologtoemail@fLS@@YAXXZ) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(logging.obj) helloworld_numeric_diff
Error 17 error LNK2001: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(vlog_is_on.obj) helloworld_numeric_diff
Error 18 error LNK1120: 1 unresolved externals C:\Users\agupta\Documents\EIS\ceres\ceres-build\bin\Release\helloworld_numeric_diff.exe helloworld_numeric_diff
Error 22 error LNK2019: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) referenced in function "void __cdecl fLS::`dynamic initializer for 'o_alsologtoemail''(void)" (??__Eo_alsologtoemail@fLS@@YAXXZ) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(logging.obj) rosenbrock
Error 23 error LNK2001: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(vlog_is_on.obj) rosenbrock
Error 24 error LNK1120: 1 unresolved externals C:\Users\agupta\Documents\EIS\ceres\ceres-build\bin\Release\rosenbrock.exe rosenbrock
Error 26 error LNK2019: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) referenced in function "void __cdecl fLS::`dynamic initializer for 'o_alsologtoemail''(void)" (??__Eo_alsologtoemail@fLS@@YAXXZ) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(logging.obj) sampled_function
Error 27 error LNK2001: unresolved external symbol "public: __thiscall google::FlagRegisterer::FlagRegisterer(char const *,char const *,char const *,char const *,void *,void *)" (??0FlagRegisterer@google@@QAE@PBD000PAX1@Z) C:\Users\agupta\Documents\EIS\ceres\ceres-build\examples\glog.lib(vlog_is_on.obj) sampled_function
Error 28 error LNK1120: 1 unresolved externals C:\Users\agupta\Documents\EIS\ceres\ceres-build\bin\Release\sampled_function.exe sampled_function

Thomas Sharpless

unread,
May 2, 2016, 12:15:31 AM5/2/16
to ceres-...@googlegroups.com
Aditya,

This looks like a missing gflags library.   Gflags is required by most of the example programs but not by ceres itself, and glog can be built without it also (uncheck "With_gflags" in CMake-gui).  My ceres dlls use a static glog library built without gflags, because it just seemed like another source of needless fuss.  But if you want to run the samples I guess you will have to supply it.


--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/cR8SSDPFvAk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/d065576a-1d46-4bc4-bbd5-3ee3d15376ea%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages