Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling on RPM-based distro, local installation of packages. #19

Open
theoden8 opened this issue Jun 1, 2017 · 1 comment
Open

Compiling on RPM-based distro, local installation of packages. #19

theoden8 opened this issue Jun 1, 2017 · 1 comment
Labels

Comments

@theoden8
Copy link
Member

theoden8 commented Jun 1, 2017

Need help finding a good fix for successfully building and running front-end on Fedora 24 as non-sudo user (#11).

Here's a bad one:

  1. Find these files:
assimp-3.2.0-3.fc24.x86_64.rpm
assimp-devel-3.2.0-3.fc24.i686.rpm
glew-devel-1.13.0-2.fc24.i686.rpm
glfw-3.2.1-1.fc24.x86_64.rpm
glfw-devel-3.2.1-1.fc24.i686.rpm
glm-devel-0.9.6.1-2.fc22.x86_64.rpm
irrXML-1.8.4-1.fc24.x86_64.rpm
libaesgm-20090429-12.fc24.x86_64.rpm
libGLEW-1.13.0-2.fc24.x86_64.rpm
libsndfile-1.0.28-1.fc24.x86_64.rpm
libsndfile-devel-1.0.28-1.fc24.x86_64.rpm
minizip-1.2.8-10.fc24.x86_64.rpm
openal-soft-devel-1.17.2-2.fc24.i686.rpm
poly2tri-0.0-11.20130501hg26242d0aa7b8.fc24.x86_64.rpm

(See 6)

  1. Install each rpm with the following script:
#!/bin/bash

installdir=~/.local/

rpminstall() {
  rpmfile=$1; shift
  rpm2cpio "$rpmfile" | cpio -idmv 2>&1 | while IFS= read -r line; do
    [ -f "$line" ] && {
      echo mkdir -vp "$installdir/$(dirname "$line")"
      echo mv -v "$line" "$installdir/$line"
    }
  done
}

for f in $*; do
  rpminstall "$f"
done
  1. Go and link all libsndfile.so.3.2.1 <- libsndfile.so.3.2 <- libsndfile.so.3 <- libsndfile.so. For all shared libraries.

  2. Export the following:

export PKG_CONFIG_PATH=$HOME/.local/usr/lib/pkgconfig:$HOME/.local/usr/lib64/pkgconfig:$HOME/.local/usr/share/pkgconfig/
export LD_LIBRARY_PATH=$HOME/.local/usr/lib:$HOME/.local/usr/lib64
  1. CMakeLists.txt (changing all cmake modules it cant find to pkg-configs which it can find).
cmake_minimum_required(VERSION 2.8.2)

project(frontend)

message("C++ Compilter ${CMAKE_CXX_COMPILER}")

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
        message(FATAL_ERROR "GCC version must be at least 4.8 to support OpenMP")
    endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
        message(FATAL_ERROR "Clang version must be at least 3.8 to support OpenMP.")
    endif()
else()
    message(WARNING "You are using unsupported compiler, and will probably have to change the source code.")
endif()

set(OPTFLAGS "-g3")
add_compile_options(-std=c++1y)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTFLAGS} -Wno-deprecated -Wno-delete-non-virtual-dtor")

set(exec planetarium)
file(GLOB SRCS ./*.cpp)
add_executable(${exec} ${SRCS})

find_package(PkgConfig)

#find_package(PNG16 REQUIRED)
pkg_search_module(PNG REQUIRED libpng16)
pkg_check_modules(LIBPNG libpng16 REQUIRED)
if(PNG_FOUND)
  message("using ${PNG_LIBRARIES} ${PNG_INCLUDE_DIRS}")
  include_directories(${PNG_INCLUDE_DIRS})
  target_link_libraries(${exec} ${PNG_LIBRARIES})
else()
  message(FATAL_ERROR "PNG not found")
endif(PNG_FOUND)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/cs/home/krb5/.local/usr/include -L/cs/home/krb5/.local/usr/lib -L/cs/home/krb5/.local/usr/lib64")
#find_package(GLM REQUIRED)
#if(GLM_FOUND)
#  message("using ${GLM_INCLUDE_DIRS}")
#  include_directories(${GLM_INCLUDE_DIRS})
#else()
#  message(FATAL_ERROR "GLM not found")
#endif(GLM_FOUND)

find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
  message("using ${OPENGL_LIBRARIES} ${OPENGL_INCLUDE_DIRS}")
  include_directories(${OPENGL_INCLUDE_DIRS})
  target_link_libraries(${exec} ${OPENGL_LIBRARIES})
else()
  message(FATAL_ERROR "OpenGL not found")
endif(OPENGL_FOUND)

#find_package(GLFW3 REQUIRED)
pkg_search_module(GLFW3 REQUIRED glfw3)
pkg_check_modules(GLFW3 glfw3 REQUIRED)
if(GLFW3_FOUND)
  message("using ${GLFW3_LIBRARIES} ${GLFW3_INCLUDE_DIRS}")
  include_directories(${GLFW3_INCLUDE_DIRS})
  target_link_libraries(${exec} ${GLFW3_LIBRARIES})
else()
  message(FATAL_ERROR "GLFW3 not found")
endif(GLFW3_FOUND)

pkg_search_module(GLEW REQUIRED glew)
pkg_check_modules(GLEW glew REQUIRED)
#find_package(GLEW REQUIRED)
if(GLEW_FOUND)
  message("using ${GLEW_LIBRARIES} ${GLEW_INCLUDE_DIRS}")
  include_directories(${GLEW_INCLUDE_DIRS})
  target_link_libraries(${exec} ${GLEW_LIBRARIES})
else()
  message(FATAL_ERROR "GLEW not found")
endif(GLEW_FOUND)

find_package(ASSIMP REQUIRED)
if(ASSIMP_FOUND)
  message("using ${ASSIMP_LIBRARIES} ${ASSIMP_INCLUDE_DIRS}")
  include_directories(${ASSIMP_INCLUDE_DIRS})
  target_link_libraries(${exec} ${ASSIMP_LIBRARIES})
else()
  message(FATAL_ERROR "ASSIMP not found")
endif(ASSIMP_FOUND)

find_package(Freetype REQUIRED)
if(FREETYPE_FOUND)
  message("using ${FREETYPE_LIBRARIES} ${FREETYPE_INCLUDE_DIRS}")
  include_directories(${FREETYPE_INCLUDE_DIRS})
  target_link_libraries(${exec} ${FREETYPE_LIBRARIES})
else()
  message(FATAL_ERROR "FREETYPE not found")
endif(FREETYPE_FOUND)

#find_package(OpenAL REQUIRED)
pkg_search_module(OPENAL REQUIRED openal)
pkg_check_modules(OPENAL openal REQUIRED)
if(OPENAL_FOUND)
  message("using ${OPENAL_LIBRARY} ${OPENAL_INCLUDE_DIRS}")
  include_directories(${OPENAL_INCLUDE_DIRS})
  target_link_libraries(${exec} ${OPENAL_LIBRARIES})
else()
  message(FATAL_ERROR "OPENAL not found")
endif(OPENAL_FOUND)

find_package(JPEG REQUIRED)
if(JPEG_FOUND)
  message("using ${JPEG_LIBRARY} ${JPEG_INCLUDE_DIR}")
  include_directories(${JPEG_INCLUDE_DIR})
  target_link_libraries(${exec} ${JPEG_LIBRARY})
else()
  message(FATAL_ERROR "JPEG not found")
endif(JPEG_FOUND)

find_package(TIFF REQUIRED)
if(TIFF_FOUND)
  message("using ${TIFF_LIBRARY} ${TIFF_INCLUDE_DIR}")
  include_directories(${TIFF_INCLUDE_DIR})
  target_link_libraries(${exec} ${TIFF_LIBRARY})
else()
  message(FATAL_ERROR "TIFF not found")
endif(TIFF_FOUND)

# find_package(LibSndFile REQUIRED)
pkg_search_module(SNDFILE REQUIRED sndfile)
pkg_check_modules(SNDFILE sndfile REQUIRED)
if(SNDFILE_FOUND)
  message("using ${SNDFILE_LIBRARIES} ${SNDFILE_INCLUDE_DIRS}")
  include_directories(${SNDFILE_INCLUDE_DIRS})
  target_link_libraries(${exec} ${SNDFILE_LIBRARIES})
else()
  message(FATAL_ERROR "SNDFILE not found")
endif(SNDFILE_FOUND)

#find_package(OpenMP REQUIRED)
#if(OPENMP_FOUND)
#  message("using OpenMP")
#  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
#  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
#endif(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -fopenmp") # -v for verbosity
message("CMAKE CXX FLAGS ${CMAKE_CXX_FLAGS}")
  1. Compile, link and find out that it fails in runtime at glewInit(), probably because the version of libglew-dev needs to be >2.
@theoden8 theoden8 changed the title Compiling on RPM-based distro, no root. Compiling on RPM-based distro, local installation of packages. Jun 1, 2017
@theoden8 theoden8 added the bug label Jun 1, 2017
@theoden8
Copy link
Member Author

Using homebrew for linux (linuxbrew):

brew install mesa glew glfw3 clinfo pocl openal-soft jpeg-turbo libpng libtiff libsndfile assimp freetype

If something fails, try running brew install <package> --env=std, if it still fails, brew install <package> --debug

Will install all the packages.
Next, check that your opencl implementation is OK by running clinfo, and OpenGL by running glxinfo. glxgears will demonstrate that it works.

Next, change all non-working cmake find_package entries to pkg-config like this:

cmake_minimum_required(VERSION 2.8.2)
project(frontend)

message("C++ Compiler ${CMAKE_CXX_COMPILER}")

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
        message(FATAL_ERROR "GCC version must be at least 4.8 to support OpenMP")
    endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
        message(FATAL_ERROR "Clang version must be at least 3.8 to support OpenMP.")
    endif()
else()
    message(WARNING "You are using unsupported compiler, and will probably have to change the source code.")
endif()

add_compile_options(-std=c++1y)

set(exec planetarium)
file(GLOB SRCS ./*.cpp)
add_executable(${exec} ${SRCS})
set_property(TARGET ${exec} PROPERTY CXX_STANDARD 14)

find_package(PkgConfig)

#find_package(PNG16 REQUIRED)
pkg_search_module(PNG REQUIRED libpng16)
pkg_check_modules(LIBPNG libpng16 REQUIRED)
if(PNG_FOUND)
  message("using ${PNG_LIBRARIES} ${PNG_INCLUDE_DIRS}")
  include_directories(${PNG_INCLUDE_DIRS})
  target_link_libraries(${exec} ${PNG_LIBRARIES})
else()
  message(FATAL_ERROR "PNG not found")
endif(PNG_FOUND)

find_package(GLM REQUIRED)
if(GLM_FOUND)
  message("using ${GLM_INCLUDE_DIRS}")
  include_directories(${GLM_INCLUDE_DIRS})
else()
  message(FATAL_ERROR "GLM not found")
endif(GLM_FOUND)

find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
  message("using ${OPENGL_LIBRARIES} ${OPENGL_INCLUDE_DIRS}")
  include_directories(${OPENGL_INCLUDE_DIRS})
  target_link_libraries(${exec} ${OPENGL_LIBRARIES})
else()
  message(FATAL_ERROR "OpenGL not found")
endif(OPENGL_FOUND)

#find_package(GLFW3 REQUIRED)
pkg_search_module(GLFW3 REQUIRED glfw3)
pkg_check_modules(GLFW3 glfw3 REQUIRED)
if(GLFW3_FOUND)
  message("using ${GLFW3_LIBRARIES} ${GLFW3_INCLUDE_DIRS}")
  include_directories(${GLFW3_INCLUDE_DIRS})
  target_link_libraries(${exec} ${GLFW3_LIBRARIES})
else()
  message(FATAL_ERROR "GLFW3 not found")
endif(GLFW3_FOUND)

find_package(GLEW REQUIRED)
if(GLEW_FOUND)
  message("using ${GLEW_LIBRARIES} ${GLEW_INCLUDE_DIRS}")
  include_directories(${GLEW_INCLUDE_DIRS})
  target_link_libraries(${exec} ${GLEW_LIBRARIES})
else()
  message(FATAL_ERROR "GLEW not found")
endif(GLEW_FOUND)

find_package(ASSIMP REQUIRED)
if(ASSIMP_FOUND)
  message("using ${ASSIMP_LIBRARIES} ${ASSIMP_INCLUDE_DIRS}")
  include_directories(${ASSIMP_INCLUDE_DIRS})
  target_link_libraries(${exec} ${ASSIMP_LIBRARIES})
else()
  message(FATAL_ERROR "ASSIMP not found")
endif(ASSIMP_FOUND)

find_package(Freetype REQUIRED)
if(FREETYPE_FOUND)
  message("using ${FREETYPE_LIBRARIES} ${FREETYPE_INCLUDE_DIRS}")
  include_directories(${FREETYPE_INCLUDE_DIRS})
  target_link_libraries(${exec} ${FREETYPE_LIBRARIES})
else()
  message(FATAL_ERROR "FREETYPE not found")
endif(FREETYPE_FOUND)

find_package(OpenAL REQUIRED)
if(OPENAL_FOUND)
  message("using ${OPENAL_LIBRARY} ${OPENAL_INCLUDE_DIR}")
  include_directories(${OPENAL_INCLUDE_DIR})
  target_link_libraries(${exec} ${OPENAL_LIBRARY})
else()
  message(FATAL_ERROR "OPENAL not found")
endif(OPENAL_FOUND)

pkg_search_module(JPEGTURBO REQUIRED libturbojpeg)
if(JPEGTURBO_FOUND)
  message("using ${JPEGTURBO_LIBRARIES} ${JPEGTURBO_INCLUDE_DIRS}")
  include_directories(${JPEGTURBO_INCLUDE_DIRS})
  target_link_libraries(${exec} ${JPEGTURBO_LIBRARIES})
else()
  find_package(JPEG REQUIRED)
  if(JPEG_FOUND)
    message("using ${JPEG_LIBRARY} ${JPEG_INCLUDE_DIR}")
    include_directories(${JPEG_INCLUDE_DIR})
    target_link_libraries(${exec} ${JPEG_LIBRARY})
  else()
    message(FATAL_ERROR "JPEG not found")
  endif(JPEG_FOUND)
endif(JPEGTURBO_FOUND)

find_package(TIFF REQUIRED)
if(TIFF_FOUND)
  message("using ${TIFF_LIBRARY} ${TIFF_INCLUDE_DIR}")
  include_directories(${TIFF_INCLUDE_DIR})
  target_link_libraries(${exec} ${TIFF_LIBRARY})
else()
  message(FATAL_ERROR "TIFF not found")
endif(TIFF_FOUND)

#find_package(LibSndFile REQUIRED)
pkg_search_module(SNDFILE REQUIRED sndfile)
if(SNDFILE_FOUND)
  message("using ${SNDFILE_LIBRARIES} ${SNDFILE_INCLUDE_DIRS}")
  include_directories(${SNDFILE_INCLUDE_DIRS})
  target_link_libraries(${exec} ${SNDFILE_LIBRARIES})
else()
  message(FATAL_ERROR "SNDFILE not found")
endif(SNDFILE_FOUND)

#find_package(OpenMP REQUIRED)
#if(OPENMP_FOUND)
#  message("using OpenMP")
#  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
#  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
#endif(OPENMP_FOUND)

find_packagE(OpenCL REQUIRED)
if(OpenCL_FOUND)
  message("using OpenCL")
  include_directories(${OpenCL_INCLUDE_DIRS})
  target_link_libraries(${exec} ${OpenCL_LIBRARIES})
else()
  message(FATAL ERROR "OPENCL not found")
endif(OpenCL_FOUND)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")

It should compile with clang:

export CXX=$(which clang++)
cmake . -DCMAKE_BUILD_TYPE=Debug
make

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant