Can't compile examples in Windows 7 64 bit

Issue #159 resolved
Adam Rutkowski created an issue

I cannot seem to build the examples in gtsam 3.2.0 on my 64-bit Windows system. I am using cmake 2.8.12.2 and Microsoft Visual Studio 2013 Express. It appears that it is trying to link against several .lib files, but these .lib files don't exist. So it seems I am doing something out of order, but I just can't figure it out.

Here are the steps I took:

  1. Installed Boost 1.57
  2. Opened CMake GUI, set source code directory to C:/gtsam-3.2.0, set build directory to C:/gtsam-3.2.0/build
  3. Set GTSAM_DIR to C:/gtsam-3.2.0/build
  4. Added an entry BOOST_ROOT and set it to C:/boost_1_57_0
  5. Changed CMAKE_INSTALL_PREFIX to C:/GTSAM
  6. Only checked the following items: GTSAM_GUILD_EXAMPLES_ALWAYS, GTSAM_BUILD_STATIC_LIBRARY, GTSAM_BUILD_TESTS, GTSAM_BUILD_TYPE_POSTFIXES, GTSAM_THROW_CHEIRALITY_EXCEPTION, GTSAM_WRAP_SERIALIZATION, and PACKAGE_DEBUG_LIBS
  7. Clicked 'Configure', followed by 'Generate'.
  8. Got some error related to finding Boost files that was I was able to fix by renaming a bunch of files in the boost_1_57_0/stage/lib directory. For example, I changed libboost_serialization-vc120-mt-1_57.lib to boost_serialization-vc120-mt-1_57.lib, and repeated this for chrono, date_time, filesystem, program_options, regex, system, thread, and timer.
  9. After clicking 'Configure' and 'Generate' again in cmake, I opened the generated GTSAM.sln file in Visual Studio, selected RELEASE mode, and attempted to build INSTALL
  10. After an unsuccessful build, opened C:\gtsam-3.2.0\build\x64\Release\INSTALL\INSTALL.log and observed the following error:

Build started 11/21/2014 8:27:12 AM. 1>Project "C:\gtsam-3.2.0\build\INSTALL.vcxproj" on node 2 (Build target(s)). 1>PostBuildEvent: setlocal "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake if %errorlevel% neq 0 goto :cmEnd :cmEnd endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone :cmErrorLevel exit /b %1 :cmDone if %errorlevel% neq 0 goto :VCEnd :VCEnd -- Install configuration: "Release" -- Up-to-date: C:/GTSAM/include/gtsam/3rdparty/gtsam_eigen_includes.h -- Up-to-date: C:/GTSAM/CMake/gtsam_extra.cmake -- Up-to-date: C:/GTSAM/CMake/GTSAMConfig.cmake -- Up-to-date: C:/GTSAM/CMake/GTSAM-exports.cmake -- Installing: C:/GTSAM/CMake/GTSAM-exports-release.cmake -- Up-to-date: C:/GTSAM/include/gtsam/global_includes.h -- Up-to-date: C:/GTSAM/include/gtsam/config.h -- Up-to-date: C:/GTSAM/include/gtsam/dllexport.h CMake Error at gtsam/cmake_install.cmake:45 (FILE): file INSTALL cannot find "C:/gtsam-3.2.0/build/lib/Release/libgtsam.lib". Call Stack (most recent call first): cmake_install.cmake:95 (INCLUDE)

  1. Since step 10 failed, I tried just building OdometryExample separately, since it is claimed that it is not necessary to install gtsam if build directory is set as in step 3 above. but I got the following error:

Error 1 error LNK1181: cannot open input file '..\lib\Release\libgtsam.lib'

  1. If I remove ..\lib\Release\lib from the list of included lib files and try building again, I get a bunch of unresolved external symbols, so libgtsam.lib seems to be needed.

Any help you can provide is greatly appreciated.

Comments (10)

  1. Chris Beall

    It looks like static build for 3.2 is slightly broken! Sorry about that. Please uncheck GTSAM_BUILD_STATIC_LIBRARY in CMake, and try again. I was able to successfully build that just now, with the exception of a timing script (Just delete the timing script from the VS solution.)

    I also recommend you undo the boost library renaming (Maybe just reinstall?) For future reference, to force usage of the static Boost libraries, in CMake you can define bool Boost_USE_STATIC_LIBS=true.

    Another useful CMake option is Boost_DEBUG=true, which will turn on verbose mode for the FindBoost script. It'll tell you which library names it's trying while attempting to find boost.

    I'll make sure static build works again for the upcoming 4.0 release. Some of the necessary fixes have already been made in develop.

  2. Adam Rutkowski reporter

    Hi @cbeall3,

    Thanks for the reply.

    Unchecking GTSAM_BUILD_STATIC_LIBRARY still doesn't help me. I think it may have been unchecked initially, but I tried checking it to create the necessary lib files (I was just guessing that is what this option is for).

    When I go to the solution file, and try to build OdometryExample, in Release mode, I get the following error:

    Error 1 error LNK1181: cannot open input file '..\lib\Release\libgtsam.lib'

    And in Debug mode, I get the following error:

    Error 1 error LNK1104: cannot open file '..\lib\Debug\gtsamDebug.lib'

    This is the basically the same problem I was having before.

    As for renaming the Boost files, defining Boost_USE_STATIC_LIBS=true does indeed fix the issue. I think I discovered my oringial work-around by using Boost_DEBUG as you suggested, then I noticed the mismatch in the naming. If I remove the files that I renamed from the directory (I left the originals in there), and delete the cache in cmake, then try to configure, I get an error, but again, setting Boost_USE_STATIC_LIBS=true fixes the problem.

    Nevertheless, I still can't build the examples. If I uncheck all of the options except for Boost_USE_STATIC_LIBS, I get the following error in the INSTALL.log file when I attempt to build INSTALL:

         -- Up-to-date: C:/GTSAM/include/gtsam/dllexport.h
         CMake Error at gtsam/cmake_install.cmake:61 (FILE):
           file INSTALL cannot find "C:/gtsam-3.2.0/build/bin/Release/gtsam.dll".
    

    I even tried building the gtsam project by itself, but that was also unsuccessful, with the following errors:

    Error 1 error C1001: An internal error has occurred in the compiler. C:\gtsam-3.2.0\gtsam\geometry\Rot3M.cpp 243 1 gtsam Error 3 error C2338: binding rvalue references to optional lvalue references is disallowed (....\gtsam\discrete\DiscreteFactorGraph.cpp) C:\boost_1_57_0\boost\optional\optional.hpp 188 1 gtsam Error 2 error C2338: binding rvalue references to optional lvalue references is disallowed (....\gtsam\symbolic\SymbolicFactorGraph.cpp) C:\boost_1_57_0\boost\optional\optional.hpp 188 1 gtsam Error 4 error D8040: error creating or communicating with child process C:\gtsam-3.2.0\build\gtsam\cl gtsam

  3. Chris Beall

    I think it'll be easiest to get this working for you with Boost_USE_STATIC_LIBS=true, and GTSAM_BUILD_STATIC_LIBRARY=false.

    With GTSAM_BUILD_STATIC_LIBRARY unchecked, we should get lib/Release/gtsam.lib and bin/Release/gtsam.dll. If it's still trying to link against libgtsam.lib maybe Visual studio didn't reload the solution properly after re-running CMake. Restart Visual studio to make sure.

    INSTALL probably didn't try to build properly before actually installed. So try Build->Solution first. (Or build the ALL_BUILD target in Solution explorer)

    The rvalue issue was already fixed, but only for Boost 1.56. I checked a fix into develop. To fix in the 3.2 release, please edit top-level CMakeLists.txt. Replace if(${Boost_VERSION} EQUAL 105600) with if(NOT (${Boost_VERSION} LESS 105600)). I haven't tried Boost 1.57 yet, but hopefully that's the only problem we'll run into with 1.57.

  4. Adam Rutkowski reporter

    The change to CMakeLists.txt does indeed fix the rvalue issue, but it is still trying to link against gtsam.lib before it is generated. I even deleted the build directory and generated a new one with CMake, and made sure I waited until Visual Studio was "ready" before I attempted any builds.

    I also tried ALL_BUILD, but it doesn't seem to do much.

    If I try to build the entire solution, or just the gtsam project, I get the following errors:

     1>..\..\gtsam\geometry\Rot3M.cpp(243): fatal error C1001: An internal error has occurred in the compiler.
         (compiler file 'msc1.cpp', line 1325)
          To work around this problem, try simplifying or changing the program near the locations listed above.
         Please choose the Technical Support command on the Visual C++ 
          Help menu, or open the Technical Support help file for more information
     1>cl : Command line error D8040: error creating or communicating with child process
     1>Done Building Project "C:\gtsam-3.2.0\build\gtsam\gtsam.vcxproj" (Rebuild target(s)) -- FAILED.
    

    I tried checking the flag for GTSAM_ROT3_EXPMAP in cmake, but I still get the same error on the exact same line of Rot3M.cpp. In case your line numbering is different, that line is

    return (*this)*CayleyFixed<3>(-Omega/2);
    

    in the retract member function.

  5. Adam Rutkowski reporter

    Success!! Installing Update 4 did the trick. I was still using the RTM release. Thanks for all the help!

    I also had to rebuild boost for 64 bit, which apparently doesn't happen if you naively follow the command line installation instructions in the getting started guide for boost (boostrap followed by b2). If instead I do

    bootstrap b2 --toolset=msvc-12.0 --build-type=complete architecture=x86 address-model=64 stage

    everything works, and I notice that my boost_1_57_0\stage\lib directory now has both .lib files and .dll files. Furthermore .lib files that aren't preceded with 'lib' are now in this directory, as are the ones that are preceded by 'lib'. Thus, Boost_USE_STATIC_LIBS=true may no longer be necessary.

    Perhaps at this point it is worth mentioning that the .zip file posted on the website for gtsam 3.2.0 seems to be incomplete. I guess I have a habit of going for .zip files when I'm on a Windows machine. Notably, GtsamMakeConfigFile is missing, and I think the license file is missing as well. The tarball, however, is complete.

  6. Chris Beall

    I checked the zip file, and its content is identical to the tgz archive. Something probably went wrong when you unzipped the file.

  7. Log in to comment