Skip to content

Commit

Permalink
Tweaks to build on Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiawen Chen committed Nov 29, 2016
1 parent 8c5721e commit 4daab14
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 86 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if( APPLE )
# Clang only
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++" )
elseif( UNIX )
message( "CMAKE_CXX_COMPILER_ID is: ${CMAKE_CXX_COMPILER_ID}" )
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
# Use libc++ with Clang.
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++" )
Expand Down Expand Up @@ -55,7 +56,7 @@ endif()

option( BUILD_CUDA "Build CUDA module." ON )
if( BUILD_CUDA )
add_subdirectory( CUDA )
add_subdirectory( cuda )
endif()

option( BUILD_OPENCV_INTEROP "Build OpenCV Interop module." ON )
Expand Down
59 changes: 31 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,31 @@ core:
GL:

* GPU drivers with OpenGL >= 4.5.
* GLEW >= 1.13.0.
* GLEW >= 2.0.0.

CUDA:
cuda:

* NVIDIA CUDA Toolkit 7.5.
* NVIDIA CUDA Samples (for cutil).

Kinect1x:
camera_wrappers/Kinect1x:

* Microsoft Kinect SDK 1.8.
* Qt (soon to be removed).

camera_wrappers/OpenNI2:

* OpenNI 2.2.0.33 Beta.

QDirectX:

* Qt 5.
* Microsoft DirectX SDK (10 depends on 10, 11 depends on 11)

QtInterop:
qt_interop:

* Qt 5.

OpenCVInterop:
opencv_interop:

* OpenCV 3.0 or 3.1.

Expand All @@ -59,22 +62,22 @@ video:
Building for Desktop
====================

On desktop, libcgt uses CMake 3.1+.
On desktop, libcgt uses CMake 3.4.3+.

Windows
-------

Set the `CMAKE_PREFIX_PATH` environment variable to where dependencies live. For
example, I put all my libraries under c:\work\libraries. To find GLEW, do the
following:
example, I put all my libraries under c:\opt\local, which have as subdirectories
bin, include, and lib. To find GLEW, do the following:

`set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;c:\work\libraries\glew-1.13.0;c:\work\libraries\glew-1.13.0\lib\Release\x64`
`set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;c:\opt\local`

To find OpenCV, use:
`set OpenCV_DIR=c:\work\libraries\opencv-3.1.0\build`
To find OpenCV, use:
`set OpenCV_DIR=c:\opt\local\opencv-3.1.0\build`

By CMake convention, you should put the generated Visual Studio solution in a build directory:
`$ mkdir build`
`$ mkdir build`
`$ cmake-gui ..`

OS X
Expand All @@ -84,7 +87,7 @@ MacPorts versions of all dependencies work great out of the box. CMake is able
to find them from /opt.

By CMake convention, you should put the generated Xcode project or Makefiles in a build directory:
`$ mkdir build`
`$ mkdir build`
`$ cmake-gui ..`

Ubuntu 14.04
Expand All @@ -94,33 +97,33 @@ Qt 5 from the default repository is sufficient.
`$ sudo aptitude install qt5-default`

You will need download and build more recent versions of GLEW and OpenCV. I put
these libraries under ~/work/libs. I built glew under ~/work/libs/glew-1.13.0,
which contains as subdirectories bin, include, and lib. Add the following to
your .bashrc:
these libraries under `~/opt/local`. I built GLEW under `~/opt/local`, which
contains as subdirectories `bin`, `include`, and `lib`. Add the following to
your `.bashrc`:

`set CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:~/work/libs/glew-1.13.0`
`export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:~/opt/local`

To build and install OpenCV:

`cd <opencv_dir>`
`mkdir build`
`cd build`
`cmake-gui -D CMAKE_INSTALL_PREFIX=~/work/libs/opencv-3.1.0 ..`
`cd <opencv_dir>`
`mkdir build`
`cd build`
`cmake-gui -D CMAKE_INSTALL_PREFIX=~/opt/local ..`
`make -j32`

~/work/libs/opencv-3.1.0 should contain as subdirectories bin, include, lib, and
share.
`~/opt/local` should contain as subdirectories `bin`, `include`, `lib`, and
`share`.

`set OpenCV_DIR=~/work/libs/opencv-3.1.0`

Apparently, gcc-4.8 has trouble building libcgt. We use Clang 3.5+ instead:

`mkdir build`
`cd build`
`CC=/usr/bin/clang-3.5 CXX=/usr/bin/clang++-3.5 cmake-gui-3.4.3 -DCMAKE_INSTALL_PREFIX=/mnt/ssd840/work/libs ..`
`mkdir build`
`cd build`
`cmake -DCMAKE_CXX_COMPILER=clang++-3.5 -DCMAKE_INSTALL_PREFIX=~/opt/local ..`

Building for Android
====================

`cd build_android`
`cd build_android`
`./build.sh`
22 changes: 12 additions & 10 deletions core/src/common/ArrayView.inl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ bool Array1DReadView< T >::packed() const
template< typename T >
Array1DWriteView< T >::Array1DWriteView( void* pointer,
size_t size ) :
Array1DReadView( pointer, size ),
Array1DReadView< T >( pointer, size ),
m_write_pointer( reinterpret_cast< uint8_t* >( pointer ) )
{

Expand All @@ -116,7 +116,7 @@ Array1DWriteView< T >::Array1DWriteView( void* pointer,
template< typename T >
Array1DWriteView< T >::Array1DWriteView( void* pointer,
size_t size, std::ptrdiff_t stride ) :
Array1DReadView( pointer, size ),
Array1DReadView< T >( pointer, size, stride ),
m_write_pointer( reinterpret_cast< uint8_t* >( pointer ) )
{

Expand All @@ -138,7 +138,7 @@ template< typename T >
T* Array1DWriteView< T >::elementPointer( size_t x ) const
{
return reinterpret_cast< T* >(
&( m_write_pointer[ x * elementStrideBytes() ] ) );
&( m_write_pointer[ x * this->elementStrideBytes() ] ) );
}

template< typename T >
Expand Down Expand Up @@ -307,7 +307,7 @@ Array1DReadView< T > Array2DReadView< T >::column( int x )
template< typename T >
Array2DWriteView< T >::Array2DWriteView( void* pointer,
const Vector2i& size ) :
Array2DReadView( pointer, size ),
Array2DReadView< T >( pointer, size ),
m_write_pointer( reinterpret_cast< uint8_t* >( pointer ) )
{

Expand All @@ -316,7 +316,7 @@ Array2DWriteView< T >::Array2DWriteView( void* pointer,
template< typename T >
Array2DWriteView< T >::Array2DWriteView( void* pointer,
const Vector2i& size, const Vector2i& stride ) :
Array2DReadView( pointer, size ),
Array2DReadView< T >( pointer, size, stride ),
m_write_pointer( reinterpret_cast< uint8_t* >( pointer ) )
{

Expand All @@ -338,21 +338,22 @@ template< typename T >
T* Array2DWriteView< T >::elementPointer( const Vector2i& xy ) const
{
return reinterpret_cast< T* >(
&( m_write_pointer[ Vector2i::dot( xy, stride() ) ] ) );
&( m_write_pointer[ Vector2i::dot( xy, this->stride() ) ] ) );
}

template< typename T >
T* Array2DWriteView< T >::rowPointer( int y ) const
{
return reinterpret_cast< T* >( &( m_write_pointer[ y * stride().y ] ) );
return reinterpret_cast< T* >(
&( m_write_pointer[ y * this->stride().y ] ) );
}

template< typename T >
T& Array2DWriteView< T >::operator [] ( int k ) const
{
int x;
int y;
Indexing::indexToSubscript2D( k, size().x, x, y );
Indexing::indexToSubscript2D( k, this->size().x, x, y );
return ( *this )[ { x, y } ];
}

Expand All @@ -365,12 +366,13 @@ T& Array2DWriteView< T >::operator [] ( const Vector2i& xy ) const
template< typename T >
Array1DWriteView< T > Array2DWriteView< T >::row( int y )
{
return Array1DWriteView< T >( rowPointer( y ), size().x, stride().x );
return Array1DWriteView< T >( rowPointer( y ),
this->size().x, this->stride().x );
}

template< typename T >
Array1DWriteView< T > Array2DWriteView< T >::column( int x )
{
return Array1DWriteView< T >( elementPointer( { x, 0 } ),
size().y, stride().y );
this->size().y, this->stride().y );
}
6 changes: 4 additions & 2 deletions core/src/vecmath/Vector3f.inl
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ inline Vector3f::Vector3f( float _x, float _y, float _z ) :
}

inline Vector3f::Vector3f( const Vector2f& _xy, float _z ) :
xy( _xy ),
x( _xy.x ),
y( _xy.y ),
z( _z )
{
}

inline Vector3f::Vector3f( float _x, const Vector2f& _yz ) :
x( _x ),
yz( _yz )
y( _yz.x ),
z( _yz.y )
{
}

Expand Down
4 changes: 2 additions & 2 deletions cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ set( CUDA_SEPARABLE_COMPILATION ON )

# Add include to the set of compiler include paths
include_directories( ../core/src )
include_directories( ../gl/src/common )
include_directories( ../gl/src/GL_45 )
include_directories( ../GL/src/common )
include_directories( ../GL/src/GL_45 )

# Define CUDA_SAMPLES_ROOT:
if( WIN32 )
Expand Down
2 changes: 1 addition & 1 deletion cuda/src/DeviceOpaqueArray2D.inl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool DeviceOpaqueArray2D< T >::copyFromHost( Array2DReadView< T > src,
const Vector2i& dstOffset )
{
// TODO: Vector< 2, size_t >
if( src.size() != size() - dstOffset() )
if( src.size() != size() - dstOffset )
{
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions qt_interop/src/qimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace libcgt { namespace qt_interop {

#if( QT_VERSION >= QT_VERSION_CHECK( 5, 5, 0 ) )
Array2DWriteView< uint8_t > viewGrayscale8( QImage& q )
{
if( q.format() != QImage::Format_Grayscale8 )
Expand All @@ -14,6 +15,7 @@ Array2DWriteView< uint8_t > viewGrayscale8( QImage& q )
return Array2DWriteView< uint8_t >( q.bits(),
{ q.width(), q.height() }, { 1, q.bytesPerLine() } );
}
#endif

Array2DWriteView< uint8x3 > viewRGB32AsBGR( QImage& q )
{
Expand Down Expand Up @@ -60,6 +62,7 @@ QImage wrapAsQImage( Array2DWriteView< uint8x4 > view )
QImage::Format_ARGB32 );
}

#if( QT_VERSION >= QT_VERSION_CHECK( 5, 5, 0 ) )
QImage wrapAsQImage( Array2DWriteView< uint8_t > view )
{
if( view.isNull() || !view.elementsArePacked() )
Expand All @@ -71,5 +74,6 @@ QImage wrapAsQImage( Array2DWriteView< uint8_t > view )
view.width(), view.height(), view.rowStrideBytes(),
QImage::Format_Grayscale8 );
}
#endif

} } // qt_interop, libcgt
Loading

0 comments on commit 4daab14

Please sign in to comment.