Skip to content

Commit

Permalink
Fixed build script and builing under Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
heikohimu committed Mar 29, 2023
1 parent 399014f commit a0166f0
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 107 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
105 changes: 8 additions & 97 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
7 changes: 3 additions & 4 deletions build_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -184,7 +184,6 @@ if %ERRORLEVEL% NEQ 0 exit /b 1

cd ..\..\..


echo ----- Building cvkit -----

cd cvkit\build
Expand All @@ -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 ..
Expand Down
13 changes: 9 additions & 4 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()

Expand All @@ -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 ()
Expand Down
53 changes: 53 additions & 0 deletions tools/win_main.cc
Original file line number Diff line number Diff line change
@@ -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 <windows.h>
#include <cstdlib>

/*
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;
}

0 comments on commit a0166f0

Please sign in to comment.