[ODBC-135] Build failure due to linker error Created: 2018-02-09  Updated: 2018-06-04  Resolved: 2018-06-04

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.0.2
Fix Version/s: 2.0.17, 3.0.5

Type: Task Priority: Major
Reporter: Faiz Akhtar Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Environment:

Arch: Intel 64 bit
OS: Ubuntu 17.10


Attachments: Text File MariaDB_ODBC_Ubuntu17.txt    
Issue Links:
Problem/Incident
is caused by ODBC-136 Make Connector/C a git sub-project Closed

 Description   

While trying to build MariaDB Connector ODBC 3.0.2 from source, got the following linking error:

[ 31%] Linking C executable result2
/usr/local/mysql/lib//libmariadbclient.a(ma_compress.c.o): In function `_mariadb_compress_alloc':
/home/test/mariadb-10.2.11/libmariadb/libmariadb/ma_compress.c:55: undefined reference to `compress'
/usr/local/mysql/lib//libmariadbclient.a(ma_compress.c.o): In function `_mariadb_uncompress':
/home/test/mariadb-10.2.11/libmariadb/libmariadb/ma_compress.c:78: undefined reference to `uncompress'
collect2: error: ld returned 1 exit status
test/CMakeFiles/result2.dir/build.make:99: recipe for target 'test/result2' failed
make[2]: *** [test/result2] Error 1
CMakeFiles/Makefile2:170: recipe for target 'test/CMakeFiles/result2.dir/all' failed
make[1]: *** [test/CMakeFiles/result2.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

Editing the CMakeLists.txt file fixed the issue.

--- ../../mariadb-connector-odbc-3.0.2/CMakeLists.txt.orig    2018-01-04 09:56:24.368084074 +0000
+++ ../../mariadb-connector-odbc-3.0.2/CMakeLists.txt 2018-01-04 09:57:13.818084074 +0000
@@ -207,6 +207,14 @@
 
 ENDIF()
 
+find_package(ZLIB)
+if (ZLIB_FOUND)
+     MESSAGE(STATUS "Configuring to build with ZLIB")
+     include_directories(${ZLIB_INCLUDE_DIRS})
+     ADD_DEFINITIONS(-DHAVE_ZLIB)
+     SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} ${ZLIB_LIBRARIES})
+endif()
+
 IF(WIN32 OR WITH_OPENSSL)
   IF(WITH_OPENSSL)
     FIND_PACKAGE(OpenSSL)

Attached the build steps used. Is editing CMakeLists.txt necessary?



 Comments   
Comment by Lawrin Novitsky [ 2018-02-09 ]

We link C/ODBC against Connector/C library, which has zlib compliled in. Please try C/C v.3.0.3

Comment by Faiz Akhtar [ 2018-02-09 ]

Yes I am using using Connector-C 3.0.3. As you can see in build steps attached, I pasted its source code in libmariadb folder of mariadb server before building. Maybe I am missing some step here, or some configure parameter?

Comment by Lawrin Novitsky [ 2018-02-09 ]

Could you please provide your mariadb_config output.

Comment by Lawrin Novitsky [ 2018-02-09 ]

And thank you for your report! We appreciate this

Comment by Lawrin Novitsky [ 2018-02-09 ]

Server builds c/c without compiled in libz, but mariadb_config is supposed to have -lz then. Probably something went wrong in your scenario

Comment by Faiz Akhtar [ 2018-02-09 ]

test@117316baedab:~$ mariadb_config
Copyright 2011-2017 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: mariadb_config [OPTIONS]
  --cflags        [-I/usr/local/mysql/include/mysql -I/usr/local/mysql/include/mysql/mysql]
  --include       [-I/usr/local/mysql/include/mysql -I/usr/local/mysql/include/mysql/mysql]
  --libs          [-L/usr/local/mysql/lib/ -lmariadb -lz -ldl -lm -lpthread -lssl -lcrypto]
  --libs_r        [-L/usr/local/mysql/lib/ -lmariadb -lz -ldl -lm -lpthread -lssl -lcrypto]
  --libs_sys      [-lz -ldl -lm -lpthread -lssl -lcrypto]
  --version       [10.2.11]
  --cc_version    [3.0.3]
  --socket        [/tmp/mysql.sock]
  --port          [3306]
  --plugindir     [/usr/local/mysql/lib/plugin]
  --tlsinfo       [OpenSSL 1.0.2g]

-lz seems to be included.

Comment by Lawrin Novitsky [ 2018-06-04 ]

C/C has been made a git sub-module. This should make such linking errors not possible

Generated at Thu Feb 08 03:26:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.