knightcrawler25 / Optix-PathTracer

Simple physically based path tracer based on Nvidia's Optix Ray Tracing Engine
317 stars 36 forks source link

Fix linux compilation #7

Closed karjonas closed 4 years ago

karjonas commented 5 years ago

This is what I had to change fix compilation for Ubuntu 16.04.

merlinND commented 4 years ago

Thanks for this PR! On Ubuntu 18.10, compilation was working fine, but I was receiving a segfault when starting ./bin/optixPathTracer. I installed the DevIL image library (sudo apt install libdevil-dev), and made the following modifications to CMake to avoid using the DevIL library shipped with this repo:

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3462d7e..14a0987 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -84,6 +84,10 @@ project(OptiX-Advanced-Samples)
 # properly.
 cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)

+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
 # As of CMake 2.6 policies were introduced in order to provide a mechanism for
 # adding backwards compatibility one feature at a time.  We will just specify
 # that all policies will use version 2.6 symantics.
@@ -131,12 +135,15 @@ endif()
 find_package(CUDA 7.0 REQUIRED)
 find_package(OpenGL REQUIRED)

-set(IL_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/support/DevIL/include)
-set(IL_LIBRARIES ${PROJECT_SOURCE_DIR}/support/DevIL/lib/x64/Release/DevIL.lib)
-set(ILU_LIBRARIES ${PROJECT_SOURCE_DIR}/support/DevIL/lib/x64/Release/ILU.lib)
-set(ILUT_LIBRARIES ${PROJECT_SOURCE_DIR}/support/DevIL/lib/x64/Release/ILUT.lib)
+if(WIN32)
+    set(IL_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/support/DevIL/include)
+    set(IL_LIBRARIES ${PROJECT_SOURCE_DIR}/support/DevIL/lib/x64/Release/DevIL.lib)
+    set(ILU_LIBRARIES ${PROJECT_SOURCE_DIR}/support/DevIL/lib/x64/Release/ILU.lib)
+    set(ILUT_LIBRARIES ${PROJECT_SOURCE_DIR}/support/DevIL/lib/x64/Release/ILUT.lib)
+    find_package(DevIL)
+else()
+    find_package(DevIL REQUIRED)
+endif()

-find_package(DevIL)

 if ( OPENGL_FOUND AND OPENGL_INCLUDE_DIR )
   include_directories( ${OPENGL_INCLUDE_DIR} )

Additionally, don't forget to extract the archive provided in src/data, which contains scene data.