Ask Your Question
0

static lib cross-compile zlib error

asked 2016-03-17 05:36:06 -0600

cs4711 gravatar image

updated 2016-03-17 05:48:41 -0600

Hi,

I was able to successfully cross-compile OpenCV 3.1 for ARM on Ubuntu 14.04 by following this tutorial: http://docs.opencv.org/2.4/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.html

Now I want to build it with static libraries by adding the options

-DBUILD_SHARED_LIBS=OFF -DBUILD_ZLIB=O

resulting in

 cmake -DSOFTFP=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_ZLIB=ON -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake ../../..

CMake output:

--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ Compiler:                /usr/bin/arm-linux-gnueabi-g++  (ver 4.7.3)

...

--   Media I/O: 
--     ZLib:                        build (ver 1.2.8)
--     JPEG:                        libjpeg (ver 90)
--     WEBP:                        build (ver 0.3.1)
--     PNG:                         build (ver 1.6.19)
--     TIFF:                        build (ver 42 - 4.0.2)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     GDAL:                        NO

And I constantly get this error when running make:

...
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/trees.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/uncompr.c.o
[  2%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/zutil.c.o
Linking C static library ../lib/libzlib.a
Error running link command: No such file or directory
make[2]: *** [3rdparty/lib/libzlib.a] Error 2
make[1]: *** [3rdparty/zlib/CMakeFiles/zlib.dir/all] Error 2
make: *** [all] Error 2

I checked the 3rdparty/lib directory, and there is no libzlib.a.

Any ideas on what I'm doing wrong here? Thanks!

edit retag flag offensive close merge delete

Comments

it should be -DBUILD_SHARED_LIBS=OFF (underscore, not hyphen)

berak gravatar imageberak ( 2016-03-17 05:41:59 -0600 )edit

aaaah! thank you! this solved:

--   C/C++:
--     Built as dynamic libs?:      NO

zlib problem still remains..

cs4711 gravatar imagecs4711 ( 2016-03-17 05:46:27 -0600 )edit

can it be, it's not finding the correct linker, i.e, you toolchain is not setup correctly ?

http://answers.opencv.org/question/35...

berak gravatar imageberak ( 2016-03-17 05:52:43 -0600 )edit

do you mean these lines?:

set(FLOAT_ABI_SUFFIX "")
find_program(CMAKE_C_COMPILER NAMES arm-linux-gnueabi${FLOAT_ABI_SUFFIX}-gcc)
find_program(CMAKE_CXX_COMPILER NAMES arm-linux-gnueabi${FLOAT_ABI_SUFFIX}-g++)
set(ARM_LINUX_SYSROOT /usr/arm-linux-gnueabi${FLOAT_ABI_SUFFIX} CACHE PATH "ARM cross compilation system root")
cs4711 gravatar imagecs4711 ( 2016-03-17 06:08:17 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-11-01 03:46:59 -0600

AlaaM gravatar image

updated 2016-11-01 07:42:10 -0600

I found a workaround:

After running cmake and generating the make files, edit opencv/opencv/platforms/linux/<your_build_dir>/CMakeFiles/3.5.1/CMakeCCompiler.cmake and replace set(CMAKE_AR "CMAKE_AR-NOTFOUND") with set(CMAKE_AR "/usr/bin/arm-linux-gnueabi-ar")

Note that setting the variable CMAKE_AR in the cmake line (CMAKE_AR="/usr/bin/arm-linux-gnueabi-ar") does not work. Seems like this sets the flag to empty.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-03-17 05:36:06 -0600

Seen: 4,173 times

Last updated: Nov 01 '16