Newest android.toolchain.cmake uses gcc for shared library linking, does not link with math library (Bug #2426)


Added by Julien Hirel over 12 years ago. Updated about 12 years ago.


Status:Done Start date:2012-10-10
Priority:Normal Due date:
Assignee:Andrey Kamaev % Done:

0%

Category:android
Target version:2.4.3
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

First of all, I am not sure wether this is really a bug or a problem with users assuming too much by thinking that the math library will be automatically linked (-lm) when linking a C++ shared library.

I recently switched from the android cmake toolchain in the android-cmake project to the toolchain in the opencv repository (more up-to-date and to avoid code replication). The latest changes allow the use of variants of the stl lib (stlport, gnustl etc.).

However it seems that the new toolchain links shared libraries (even written in C++) using arm-linux-androideabi-gcc whereas the version from the android-cmake project uses g++. Any program using math functions (sqrt, floor etc.) and not explicitely linking with the math library using -lm now produces "undefined reference" errors on compilation (see attached test program and logs for comparison).

I will now link explicitely with -lm but it would be good if newer versions used g++ to link with or added -lm to the linker flags.


library.cpp (144 Bytes) Julien Hirel, 2012-10-10 12:43 pm

CMakeLists.txt (124 Bytes) Julien Hirel, 2012-10-10 12:43 pm

log_android-cmake-toolchain.txt (1.2 kB) Julien Hirel, 2012-10-10 12:43 pm

log_opencv-toolchain.txt (1.9 kB) Julien Hirel, 2012-10-10 12:43 pm


Associated revisions

Revision c46affe6
Added by Andrey Kamaev over 12 years ago

android.toolchain.cmake: restore implicit link with math library for C++ objects

Ticket #2426

History

Updated by Andrey Kamaev over 12 years ago

  • Target version deleted ()
  • Assignee changed from Andrey Pavlenko to Andrey Kamaev

Updated by Andrey Kamaev over 12 years ago

Thanks for the report.

Fix is pushed to master.

  • Status changed from Open to Done

Updated by Andrey Kamaev about 12 years ago

  • Target version set to 2.4.3

Also available in: Atom PDF