This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Ubuntu 12.04 PPA fails compiling Expressions

0 votes

I am using Ubuntu 12.04, I recently updated via PPA to dolfin 1.2.0

My code does not work when I try to use "Expression"

In [1]: from dolfin import *
In [2]: mesh = UnitCubeMesh(10,10,10)
In [3]: V=FunctionSpace(mesh,"CG",2)
In [4]: E=Expression('x[0]>12?1:2')
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
In instant.recompile: The module did not compile with command 'cmake -DDEBUG=TRUE . ', see '/home/cchintaluri/.instant/error/dolfin_compile_code_d921ff1f9a69752d5ac5a72c2e599b20/compile.log'
.
.
In [5]: dolfin.__version__
Out[5]: '1.2.0'

In [6]: dolfin.has_cgal()
Out[6]: True

The complile.log reads thus:

CMake Error at CMakeLists.txt:11 (INCLUDE):
include called with wrong number of arguments. Include only takes one
file.

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found SWIG: /usr/bin/swig2.0 (found version "2.0.4")
-- Configuring incomplete, errors occurred!

Thanks in advance!

asked Oct 29, 2013 by c-chintaluri FEniCS Novice (180 points)
edited Oct 30, 2013 by c-chintaluri

Also including the CMakeLists.txt file as suggested by [Kent-Andre Mardal][1]

CMakeLists.txt file

cmake_minimum_required(VERSION 2.6.0)

set (NAME dolfin_compile_code_c18706ac017410b222ba273d1590c713)


# Configuration for package DOLFIN
FIND_PACKAGE(DOLFIN REQUIRED)
IF(DOLFIN_FOUND)
 INCLUDE(${DOLFIN_USE_FILE})
ENDIF(DOLFIN_FOUND)


PROJECT(${NAME})

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


find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})

set(SWIG_MODULE_NAME ${NAME})
set(CMAKE_SWIG_FLAGS
  -module ${SWIG_MODULE_NAME}
  -shadow
  -modern
  -modernargs
  -fastdispatch
  -fvirtual
  -nosafecstrings
  -noproxydel
  -fastproxy
  -fastinit
  -fastunpack
  -fastquery
  -nobuildnone
${DOLFIN_CXX_DEFINITIONS}
${DOLFIN_PYTHON_DEFINITIONS}
-c++ -fcompact -O -I. -small

  )

set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR})

set(SWIG_SOURCES ${NAME}.i)

set_source_files_properties(${SWIG_SOURCES} PROPERTIES CPLUSPLUS ON)

set(EXTRA_INCLUDE_DIRS ".")
if(EXTRA_INCLUDE_DIRS)
  include_directories(${EXTRA_INCLUDE_DIRS})
endif()
include_directories(${DOLFIN_PYTHON_INCLUDE_DIRS} ${${NAME}_SOURCE_DIR})

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${DOLFIN_LINK_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${DOLFIN_LINK_FLAGS}")


set(SOURCE_FILES)

if (DEFINED DOLFIN_PYTHON_DEFINITIONS)
  add_definitions(${DOLFIN_PYTHON_DEFINITIONS})
endif()

swig_add_module(${SWIG_MODULE_NAME} python ${SWIG_SOURCES})

set(EXTRA_LIBRARIES )
if(SOURCE_FILES)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic")
  add_library(source_file_lib
    STATIC
    ${SOURCE_FILES})
  set(EXTRA_LIBRARIES "source_file_lib ${EXTRA_LIBRARIES}")
endif()

if(EXTRA_LIBRARIES)
  string(STRIP "${EXTRA_LIBRARIES}" EXTRA_LIBRARIES)
  swig_link_libraries(${SWIG_MODULE_NAME} ${EXTRA_LIBRARIES})
endif()

if (DEFINED DOLFIN_LIBRARIES OR DEFINED DOLFIN_3RD_PARTY_LIBRARIES OR DEFINED DOLFIN_PYTHON_LIBRARIES)
  swig_link_libraries(${SWIG_MODULE_NAME} ${DOLFIN_LIBRARIES} ${DOLFIN_3RD_PARTY_LIBRARIES} ${DOLFIN_PYTHON_LIBRARIES} ${EXTRA_SOURCE_LIB})
endif()

Compiling dolfin from the source solves the issue, perhaps this question / comment will address the issue with the PPA for Ubuntu 12.04.

2 Answers

0 votes

Hi, perhaps the problem is related to spacing in your ternary operator. Try adjusting your
code following answers to this question.

answered Oct 29, 2013 by MiroK FEniCS Expert (80,920 points)

Thank you for your comment. But it doesn't change the output

In [4]: a=dolfin.Expression('(x[0]>1) ? 1 : 2')

Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
In instant.recompile: The module did not compile with command 'cmake -DDEBUG=TRUE . ', see '/home/cchintaluri/.instant/error/dolfin_compile_code_60df0b618f8bbad0294e27b48bbb6091/compile.log'

0 votes

I think you need to send the CMakeLists.txt file as well.

answered Oct 31, 2013 by Kent-Andre Mardal FEniCS Expert (14,380 points)

Added the said relevant file. Thanks for the comment.

Compiling from the source resolves this issue. Perhaps an error in the PPA for Ubuntu12.04?

No, it is not an error in the PPA. I have tested it on several different setups and it works exactly as described in the answer in this question.

...