From a0166f02099a6af15da20a1cb77cf914b83ddeaa Mon Sep 17 00:00:00 2001 From: Heiko Hirschmueller Date: Wed, 29 Mar 2023 11:20:40 +0200 Subject: [PATCH] Fixed build script and builing under Windows --- CMakeLists.txt | 1 - INSTALL.md | 105 ++++--------------------------------------- LICENSE | 2 +- build_win.bat | 7 ++- tools/CMakeLists.txt | 13 ++++-- tools/win_main.cc | 53 ++++++++++++++++++++++ 6 files changed, 74 insertions(+), 107 deletions(-) create mode 100644 tools/win_main.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a27d4c..0c9e247 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,7 +198,6 @@ add_subdirectory(example) # declare dynamic and static libraries set(PROJECT_LIBRARIES gimage gmath gutil bgui gvr) - set(PROJECT_STATIC_LIBRARIES cvkit::gimage_static cvkit::gmath_static cvkit::gutil_static cvkit::bgui_static cvkit::gvr_static) # install generated version.h file diff --git a/INSTALL.md b/INSTALL.md index 7c6324f..5d5eea4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -54,102 +54,13 @@ For opening more than one file at once, a link to plyv.exe and sv.exe can be manually created on the desktop. Selecting several files, dragging and dropping them on the icon will start plyv.exe or sv.exe with all those files. -Compiling under Windows using MinGW64 / MSYS2 ---------------------------------------------- +Compiling under Windows +----------------------- -Install MSYS2 (64) from http://www.msys2.org/, e.g. -http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20161025.exe +There is a build_win.bat script that can be executed in the command prompt of +Visual Studio. It was developed with version 2019. The script checks for the +availability of git and cmake and suggests web pages for downloading if they +cannot be found. Then, it automatically downloads dependencies like freeglut, +glew, zlib, libpng, libjpeg, and libtiff, compiles everything and creates a +self installable package with NSIS, which must be available. -Add the link 'MSYS2 MinGW 64 bit' to the desktop and start it to open a bash -shell. First, update all packages: - - pacman -Syu - -Usually this has to be done twice. Then install additional packages (but do -not use the MSYS version of gcc, but only mingw-w64-...), e.g.: - - pacman -S git nano make tar gzip zip mingw-w64-x86_64-cmake - mingw-w64-x86_64-gcc mingw-w64-x86_64-freeglut mingw-w64-x86_64-glew - mingw-w64-x86_64-crypto++ mingw-w64-x86_64-eigen3 - -Optionally you may want to use GDAL. Download GDAL from -http://trac.osgeo.org/gdal/wiki/DownloadSource, -e.g. http://download.osgeo.org/gdal/2.2.0/gdal-2.2.0.tar.gz. Unpack and -change into the main directory. Then type: - - ./configure - make - make install - -Building and installing of cvkit works as under Linux. Go to the main -directory and type: - - mkdir build - cd build - cmake -G"MSYS Makefiles" .. - # (optionally you may edit the file CMakeCache.txt for changing some - # variables, like CMAKE_INSTALL_PREFIX) - make - make install - -Compiling under Windows using Visual Studio -------------------------------------------- - -It is assumed that Visual Studio 2015 (Version 14) is installed. Other -versions may work as well. - -For compiling plyv, you need to install GLEW and GLUT as well as OpenGL. -This has not yet been tested with Visual Studio. - -Optionally you may want to install GDAL. Download GDAL from -http://trac.osgeo.org/gdal/wiki/DownloadSource, -e.g. http://download.osgeo.org/gdal/2.2.0/gdal220.zip - -Extract the archive. Open PowerShell (or another shell) and go to the main -directory of the unpacked archive. Type: - - ./generate_vcxproj.bat 14.0 64 gdal_vs2015 - -Use different parameters if you have are using a different version of -Visual Studio. Double click on the generated gdal_vs2015 project file -for opening it in Visual Studio. Select 'Release' configuration in the -toolbar. Compile the project by pressing 'F7'. Close Visual Studio -after compilation ends. - -We will create an installation directory on the same level as the main -directories of the GDAL and cvkit source. The directory will be called -'install'. Open PowerShell (or another shell) and go into the main -directory of GDAL: - - mkdir ..\install\bin - cp .\apps\*.exe ..\install\bin - cp .\gdal*.dll ..\install\bin - mkdir ..\install\include\gdal - cp *\*.h ..\install\include\gdal - mkdir ..\install\lib - cp .\gdal_i.lib ..\install\lib\ - -Install cmake for Windows from https://cmake.org/download/, e.g. -https://cmake.org/files/v3.8/cmake-3.8.1-win64-x64.msi. - -- Start cmake-gui -- Select the cvkit source directory as source code path -- Copy the source code path to build the binaries and add /build to the - path -- Click 'Configure', confirm creating the build directory -- Select the appropriate Visual Studio version (e.g. 'Visual Studio 14 - 2015 Win64'), select 'Use default native compilers' and click 'Finish' -- Search for the key name 'CMAKE_INSTALL_PREFIX' and change the value to - the install path for GDAL -- Search for the key name 'USE_GDAL' and make sure that it is selected -- Click 'Configure' again to enable cmake to find GDAL. -- Click 'Generate' -- Click 'Open Project' -- In Visual Studio, select 'Release' in the toolbar -- Compile by pressing 'F7' -- In the project view on the left, select INSTALL, open the context menu - with the right mouse button and select create - -All binaries can be found in install/bin and may be copied to any other -place. sv.exe can be selected as standard application for images so that -a double click on the images opens sv automatically. diff --git a/LICENSE b/LICENSE index 1d49ed2..9f19714 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021 Roboception GmbH +Copyright (c) 2016-2023 Roboception GmbH Copyright (c) 2014, 2015 Institute of Robotics and Mechatronics, German Aerospace Center All rights reserved. diff --git a/build_win.bat b/build_win.bat index 0e51cc5..716d5ca 100644 --- a/build_win.bat +++ b/build_win.bat @@ -63,7 +63,7 @@ if not exist "%INSTALL_PATH%\lib\glew32.lib" ( copy glew-2.2.0\lib\Release\x64\glew32.lib %INSTALL_PATH%\lib ) -set OPT_GLEW=-DGLEW_INCLUDE_DIR="%CD%\glew-2.2.0\include" -DGLEW_SHARED_LIBRARY_RELEASE="%CD%\glew-2.2.0\lib\Release\x64\glew32.lib" +set OPT_GLEW=-DGLEW_INCLUDE_DIR="%INSTALL_PATH%\include" -DGLEW_SHARED_LIBRARY_RELEASE="%INSTALL_PATH%\lib\glew32.lib" if not exist "zlib\" ( git clone https://github.com/winlibs/zlib.git -b zlib-1.2.11 @@ -184,7 +184,6 @@ if %ERRORLEVEL% NEQ 0 exit /b 1 cd ..\..\.. - echo ----- Building cvkit ----- cd cvkit\build @@ -194,10 +193,10 @@ if exist "build_cvkit\" ( ) else ( mkdir build_cvkit\ cd build_cvkit\ - cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="%INSTALL_PATH%" %OPT_GLUT% %OPT_GLEW% ..\.. + cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="%INSTALL_PATH%" %OPT_GLUT% %OPT_GLEW% -DINCLUDE_DLL="%INSTALL_PATH%\bin\zlib.dll;%INSTALL_PATH%\bin\glew32.dll;%INSTALL_PATH%\bin\freeglut.dll" ..\.. ) -nmake install +nmake package if %ERRORLEVEL% NEQ 0 exit /b 1 cd .. diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 6634c9a..38d2a85 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -67,8 +67,8 @@ if (X11_FOUND AND CMAKE_USE_PTHREADS_INIT) target_link_libraries(sv bgui_static ${libs}) install(TARGETS sv DESTINATION bin) elseif (WIN32) - add_executable(sv sv.cc) - target_link_libraries(sv bgui_static ${libs} gdi32 comctl32 "-Wl,--subsystem,windows") + add_executable(sv WIN32 sv.cc win_main.cc) + target_link_libraries(sv bgui_static ${libs} comctl32) install(TARGETS sv DESTINATION bin) endif () @@ -82,9 +82,14 @@ if (USE_3D) include_directories(${GLEW_INCLUDE_DIRS}) add_definitions(-DINCLUDE_GL) - add_executable(plyv plyv.cc) - target_link_libraries(plyv GLEW::GLEW) + if (WIN32) + add_executable(plyv WIN32 plyv.cc win_main.cc) + else () + add_executable(plyv plyv.cc) + endif () + target_link_libraries(plyv GLEW::GLEW) + if (USE_FLTK) target_link_libraries(plyv ${FLTK_LIBRARIES}) else () diff --git a/tools/win_main.cc b/tools/win_main.cc new file mode 100644 index 0000000..dab43ae --- /dev/null +++ b/tools/win_main.cc @@ -0,0 +1,53 @@ +/* + * This file is part of the Computer Vision Toolkit (cvkit). + * + * Author: Heiko Hirschmueller + * + * Copyright (c) 2023, Roboception GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + + /* + WinMain function that calls main. + */ + +extern int main(int, char *[]); + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + int ret; + + ret=main(__argc, __argv); + + return ret; +} +