-1

I am using the auto-tools for compiling and executing the code. What is procedure for adding C++ mysql library in configure and makefile.am. I want to add the mysql library files in configure file and makefile.am.

How do I include mysql.h and my_global.h into the Makefile.am? this didn't helped me.

This is the Error:

Undefined symbols for architecture x86_64:

"sql::mysql::get_driver_instance()", referenced from:

  makeConnection() 

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [quaestord] Error 1

make[1]: *** [all-recursive] Error 1

make: *** [all-recursive] Error 1

1 Answers1

1

You should be able to use AX_LIB_MYSQL in your configure.ac like this:

configure.ac

AX_LIB_MYSQL([5.0])

If MySql is found (minimum version 5.0) you can use these variables in your Automake.am:

HAVE_MYSQL
MYSQL_CFLAGS
MYSQL_LDFLAGS
MYSQL_VERSION

Something like:

Makefile.am

bin_PROGRAMS = my_database_program

my_database_program_SOURCES = my_database_program.cpp

my_database_program_CXXFLAGS = $(MYSQL_CFLAGS)
my_database_program_LDFLAGS  = $(MYSQL_LDFLAGS)
Galik
  • 47,303
  • 4
  • 80
  • 117
  • Undefined symbols for architecture x86_64: "_get_driver_instance", referenced from: makeConnection() How to resolve this? – Hasnat Ahmed May 16 '19 at 09:50
  • @HasnatAhmed Have you installed the mysql development libraries? – Galik May 16 '19 at 10:04
  • yes I have installed the mysql libraries in my laptop? but how can we install it using c++ auto tools? – Hasnat Ahmed May 16 '19 at 10:08
  • Are you sure you have installed the `x86_64` version and not the `i686` version? – Galik May 16 '19 at 10:25
  • Also you need the connector development libraries, the package names of development libraries usually end in `-devel` or `-dev` (they are usually seperate from the library itself). – Galik May 16 '19 at 10:27
  • Undefined symbols for architecture x86_64: "sql::mysql::get_driver_instance()", referenced from: makeConnection() ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [quaestord] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all-recursive] Error 1 – Hasnat Ahmed May 17 '19 at 04:35