← Back to team overview

elementary-dev-community team mailing list archive

-lm and building the terminal

 

On the terminal we now need Math.floor and Math.ceil for zooming in and out
using Ctrl-+ and Ctrl--.

This brought along an issue when building the termina:

/usr/bin/ld: CMakeFiles/pantheon-terminal.dir/src/TerminalWidget.c.o:
undefined reference to symbol 'floor@@GLIBC_2.2.5'
/usr/bin/ld: note: 'floor@@GLIBC_2.2.5' is defined in DSO
/usr/lib/libm.so.6 so try adding it to the linker command line
/usr/lib/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [pantheon-terminal] Error 1

In order to fix this, Ricotz suggested using the "-lm" flag on the linker.
I tried to do it and then it worked just fine. However, for Victored and
Eshat on Ubuntu (Luna), that made it stop working.

It seems that on Ubuntu the linker includes lm by default, and on Arch it
doesn't, and reincluding it causes troubles on Ubuntu.

On CMakeLists.txt I just added the following to make it compile:

set (CMAKE_EXE_LINKER_FLAGS "-lm")

Either way, I want Pantheon Terminal to compile across all GNU/Linux
distributions, so I need a way to solve this.

=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2012-07-26 20:23:31 +0000
+++ CMakeLists.txt 2012-09-12 19:18:34 +0000
@@ -30,6 +30,7 @@
 find_package(PkgConfig)
 pkg_check_modules(DEPS REQUIRED gthread-2.0 gtk+-3.0 granite vte-2.90
libnotify gdk-3.0)

+set (DEPS_LADD "${DEPS_LADD} -lm")
 add_definitions(${DEPS_CFLAGS})

 link_libraries(${DEPS_LIBRARIES})

Ricotz suggesting the avobe path to fix the issue. I applied that patch and
my patched CMakeLists.txt is attached. However, with this patch I can't
build it on Arch, but Victored managed to built it on Ubuntu. I get the
same good old error:

/usr/bin/ld: CMakeFiles/pantheon-terminal.dir/src/TerminalWidget.c.o:
undefined reference to symbol 'floor@@GLIBC_2.2.5'
/usr/bin/ld: note: 'floor@@GLIBC_2.2.5' is defined in DSO
/usr/lib/libm.so.6 so try adding it to the linker command line
/usr/lib/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

So I'd appreciate some help guys, since I'm fairly new to CMake. Oh, and
this is the branch we're working on:

https://code.launchpad.net/~elementary-dev-community/pantheon-terminal/zoom-in-out

Thank you.
# Check http://webdev.elementaryos.org/docs/developer-guide/cmake for documentation

project (pantheon-terminal)
cmake_minimum_required (VERSION 2.8)
cmake_policy (VERSION 2.6)

list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/vala)

#
# Base bits
#

enable_testing ()

set (DATADIR "${CMAKE_INSTALL_PREFIX}/share")
set (PKGDATADIR "${DATADIR}/pantheon-terminal")
set (GETTEXT_PACKAGE "pantheon-terminal")
set (RELEASE_NAME "Fast and connected.")
set (VERSION "0.1")
set (VERSION_INFO "Release")
set (CMAKE_C_FLAGS "-ggdb")
set (PREFIX ${CMAKE_INSTALL_PREFIX})
set (DOLLAR "$")

list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

configure_file (${CMAKE_SOURCE_DIR}/src/config.vala.cmake ${CMAKE_SOURCE_DIR}/src/config.vala)
add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")

find_package(PkgConfig)
pkg_check_modules(DEPS REQUIRED gthread-2.0 gtk+-3.0 granite vte-2.90 libnotify gdk-3.0)

set (DEPS_LADD "${DEPS_LADD} -lm")
add_definitions(${DEPS_CFLAGS})

link_libraries(${DEPS_LIBRARIES})
link_directories(${DEPS_LIBRARY_DIRS})

find_package(Vala REQUIRED)
include(ValaVersion)
ensure_vala_version("0.10.0" MINIMUM)

include(ValaPrecompile)
vala_precompile(VALA_C
    src/Settings.vala
    src/PantheonTerminal.vala
    src/PantheonTerminalWindow.vala
    src/TerminalWidget.vala
    src/ForegroundProcessDialog.vala
    src/config.vala
PACKAGES
    vte-2.90
    granite
    gtk+-3.0
    libnotify
    gdk-3.0
    posix
OPTIONS
    --thread
    --vapidir=${CMAKE_CURRENT_SOURCE_DIR}/vapi/
)

include(GSettings)
add_schema ("org.elementary.pantheon-terminal.gschema.xml")

add_subdirectory (po)

add_executable(pantheon-terminal ${VALA_C})

install(TARGETS pantheon-terminal RUNTIME DESTINATION bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/pantheon-terminal.desktop DESTINATION share/applications)

Follow ups