jmcnamara / libxlsxwriter

A C library for creating Excel XLSX files.
https://libxlsxwriter.github.io
Other
1.48k stars 330 forks source link

undefined reference to symbol 'deflate' , when I cross compile #410

Closed justdomyself closed 11 months ago

justdomyself commented 11 months ago

I mv .a flie to my project, and crsoss compile my project, errors happend.

the full error messge below :

/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.3.0/real-ld: libs/arm32/lib/libxlsxwriter.a(zip.c.o): undefined reference to symbol 'deflate'
/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi/lib/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/mqt.dir/build.make:346: mqt] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/mqt.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
make failed???
justdomyself commented 11 months ago

the zlib is in my compiler, but it still has errors?

jmcnamara commented 11 months ago

You probably need to add the zlib library to your link commands with -lz or the equivalent in your Cmake file. See the following:

https://stackoverflow.com/questions/22337896/how-to-fix-undefined-references-to-inflate-deflate-functions

justdomyself commented 11 months ago

You probably need to add the zlib library to your link commands with -lz or the equivalent in your Cmake file. See the following:

https://stackoverflow.com/questions/22337896/how-to-fix-undefined-references-to-inflate-deflate-functions

I have add below line in my cmakelists.txt,but still has this error; target_link_libraries( ${TARGET} z)

justdomyself commented 11 months ago

You probably need to add the zlib library to your link commands with -lz or the equivalent in your Cmake file. See the following: https://stackoverflow.com/questions/22337896/how-to-fix-undefined-references-to-inflate-deflate-functions

I have add below line in my cmakelists.txt,but still has this error; target_link_libraries( ${TARGET} z)

I have resolve my question。

the problem is :

I install two toolchain , one is for imx6, the other is for imx8m。 they both has zlib ,but diffrent version。

1、when I build libxlsxwriter.a, I add absolute path into cmakelists.txt in line 221:

set(ZLIB_ROOT "/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/lib")

find_package(ZLIB "1.0" REQUIRED) list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}) message("zlib version: " ${ZLIB_VERSION})

2、when I build my project , I add below line in my cmakelists.txt: target_link_libraries( ${TARGET} z)