When using Autoconf and automake to create makefile files, how do I connect them to the MySQL library and header files?

Source: Internet
Author: User
Tags automake
Hello everyone, the MAKEFILE file below is hand-written and has been used very well and there is no problem.
Name = gameser
Link = g ++
Cc = gcc

Ccflags + =-G
Ccflags + =-wall
Ccflags + =-I/usr/include/MySQL
Ccflags + =-ddebug
# Ccflags + =-m

Linkopts + =-L/usr/lib/MySQL
Linkopts ++ =-lmysqlclient
Linkopts ++ =-lpthread

Cppfiles = poll. CPP/
Java. CPP/
Protocol. CPP/
Logicgbmj. CPP/
Game. cpp

$ (Name): $ (cppfiles:. cpp =. O)
$ (Link)-o $ (name) $ (cppfiles:. cpp =. O) $ (linkopts)

. Cpp. O:
$ (CC)-C $ <$ (ccflags)

Clean:
Rm-F $ (cppfiles:. cpp =. O) $ (cfiles:. c =. O) $ (name)

Recently I want to study how to use Autoconf and automake to automatically generate makefile files. The articles on the Internet are a simple hello example. It is superficial to avoid linking other people's libraries, my MAKEFILE file needs the support of the MySQL database, so I wrote configure according to the online steps. in file and makefile. am file. However, some functions in MySQL are not defined in make.
The autogen. Sh file is as follows:
#! /Bin/sh
Aclocal
Autoheader
Automake -- add-Missing
Autoconf

The Configure. In file is as follows:
#-*-Autoconf -*-
# Process this file with Autoconf to produce a configure script.

Ac_prereq (2.59)
Ac_init (full-package-name, version, bug-Report-address)
Am_init_automake (tempexe, 1.0.0)
Ac_config_srcdir ([Protocol. H])
Ac_config_header ([config. H])
Ac_config_files (makefile)
# Checks for programs.
Ac_prog_cxx
Ac_prog_cc

# Checks for libraries.

# Checks for header files.
Ac_header_stdc

Ac_check_headers ([ARPA/inet. h fcntl. h netinet/in. h string. h sys/IOCTL. h sys/socket. h sys/time. h unistd. H])
Ac_check_headers (/usr/include/MySQL. h)
Ac_check_lib (/usr/lib/MySQL/mysqlclient)

# Checks for typedefs, structures, and compiler characteristics.
Ac_header_stdbool
Ac_c_const
Ac_c_inline
Ac_type_size_t
Ac_struct_tm

# Checks for library functions.
Ac_func_fork
Ac_prog_gcc_traditional
Ac_func_malloc
Ac_func_memcmp
Ac_func_stat
Ac_func_vprintf
Ac_check_funcs ([bzero dup2 inet_ntoa memmove memset socket strstr])
Ac_output (makefile)

The makefile. Am file is as follows:
Automake_options = foreign
Bin_programs = tempexe
Tempexe_sources = game. cpp logicgbmj. cpp poll. cpp protocol. cpp qmysql. cpp java. cpp

The following prompt is suspicious when you execute./configure, that is, the mysqlclient library is not found:
Checking for/usr/include/MySQL. H... yes
Checking for In-L/usr/lib/MySQL/mysqlclient... no

./Configure: Line 7473: makefile: Command not found command not found, do not know what this line means?
Execute make as follows:
Qmysql. h: 6: 19: mysql. h: the file or directory does not exist.
In file encoded ded from game. h: 34,
From game. cpp: 2:
Qmysql. h: 25: Error: 'mysql' does not name a type
Qmysql. h: 26: Error: iso c ++ forbids declaration of 'mysql _ res' with no type
Qmysql. h: 26: Error: Expected '; 'before' *' token
Make [1]: *** [game. O] Error 1
Make [1]: Leaving directory '/home/zsj/temp'

Thank you for your advice.

Reply:X86 (heavy snow)() Credit: 120 2006-6-26 10:46:11 Score: 10
 
 
?
Without such experience, we recommend that you download the source code of other mysql-used programs (such as those tools on the MySQL website) to see how the files are written.

Top
 
Reply:Eqxu (Angel Alliance)() Credit: 100 2006-6-26 11:20:29 Score: 80
 
 
?
Primary des =-I./-I/usr/local/MySQL/include/
Libs =-L/usr/lib/MySQL-lmysqlclient

You can add the above to makefile. am. Of course, other necessary items must also be added.

Top
 
Reply:Ghtsao (dark moon)() Credit: 100 2006-6-26 13:23:26 Score: 10
 
 
?
Ccflags + =-I/usr/include/MySQL
Ccflags + =-ddebug
# Ccflags + =-m

Linkopts + =-L/usr/lib/MySQL
Linkopts ++ =-lmysqlclient
Linkopts ++ =-lpthread

This part is moved to makefile. am.

Top
 
Reply:Vcclass (Montenegro old demon)() Credit: 100 2006-6-26 13:27:05 Score: 0
 
 
?
Good, hero is the hero. After adding two lines of code, it will be OK. Xie eqxu (Angel Alliance ). I have been exploring for two days, but I have not done it. This problem is solved. Good. Although I have written a few Linux projects, the MAKEFILE file that someone else (old employee) has been using is the one that can be used above. Although it can be used, make clean the header file before modifying it, make again, otherwise it will not work. I should have done it several times, but it is not ideal. We have tried automake and Autoconf over and over again. I have heard that the feature is powerful, and the feature is powerful. I want to complain again. Don't laugh: I search for information on Chinese websites. Everyone is the same. If you copy my information, I copy yours, and no one will deepen it, for example, when making makefile files, everyone is "hello" and all are from the same person. It's hard to read English. No wonder the Chinese software industry is too far away from foreigners. It is estimated that the difference is far from that in India. There is really little first-hand information we can get. I don't know if you feel the same way. Either way, two words: "Close Up ".

Hello everyone, the MAKEFILE file below is hand-written and has been used very well and there is no problem.
Name = gameser
Link = g ++
Cc = gcc

Ccflags + =-G
Ccflags + =-wall
Ccflags + =-I/usr/include/MySQL
Ccflags + =-ddebug
# Ccflags + =-m

Linkopts + =-L/usr/lib/MySQL
Linkopts ++ =-lmysqlclient
Linkopts ++ =-lpthread

Cppfiles = poll. CPP/
Java. CPP/
Protocol. CPP/
Logicgbmj. CPP/
Game. cpp

$ (Name): $ (cppfiles:. cpp =. O)
$ (Link)-o $ (name) $ (cppfiles:. cpp =. O) $ (linkopts)

. Cpp. O:
$ (CC)-C $ <$ (ccflags)

Clean:
Rm-F $ (cppfiles:. cpp =. O) $ (cfiles:. c =. O) $ (name)

Recently I want to study how to use Autoconf and automake to automatically generate makefile files. The articles on the Internet are a simple hello example. It is superficial to avoid linking other people's libraries, my MAKEFILE file needs the support of the MySQL database, so I wrote configure according to the online steps. in file and makefile. am file. However, some functions in MySQL are not defined in make.
The autogen. Sh file is as follows:
#! /Bin/sh
Aclocal
Autoheader
Automake -- add-Missing
Autoconf

The Configure. In file is as follows:
#-*-Autoconf -*-
# Process this file with Autoconf to produce a configure script.

Ac_prereq (2.59)
Ac_init (full-package-name, version, bug-Report-address)
Am_init_automake (tempexe, 1.0.0)
Ac_config_srcdir ([Protocol. H])
Ac_config_header ([config. H])
Ac_config_files (makefile)
# Checks for programs.
Ac_prog_cxx
Ac_prog_cc

# Checks for libraries.

# Checks for header files.
Ac_header_stdc

Ac_check_headers ([ARPA/inet. h fcntl. h netinet/in. h string. h sys/IOCTL. h sys/socket. h sys/time. h unistd. H])
Ac_check_headers (/usr/include/MySQL. h)
Ac_check_lib (/usr/lib/MySQL/mysqlclient)

# Checks for typedefs, structures, and compiler characteristics.
Ac_header_stdbool
Ac_c_const
Ac_c_inline
Ac_type_size_t
Ac_struct_tm

# Checks for library functions.
Ac_func_fork
Ac_prog_gcc_traditional
Ac_func_malloc
Ac_func_memcmp
Ac_func_stat
Ac_func_vprintf
Ac_check_funcs ([bzero dup2 inet_ntoa memmove memset socket strstr])
Ac_output (makefile)

The makefile. Am file is as follows:
Automake_options = foreign
Bin_programs = tempexe
Tempexe_sources = game. cpp logicgbmj. cpp poll. cpp protocol. cpp qmysql. cpp java. cpp

The following prompt is suspicious when you execute./configure, that is, the mysqlclient library is not found:
Checking for/usr/include/MySQL. H... yes
Checking for In-L/usr/lib/MySQL/mysqlclient... no

./Configure: Line 7473: makefile: Command not found command not found, do not know what this line means?
Execute make as follows:
Qmysql. h: 6: 19: mysql. h: the file or directory does not exist.
In file encoded ded from game. h: 34,
From game. cpp: 2:
Qmysql. h: 25: Error: 'mysql' does not name a type
Qmysql. h: 26: Error: iso c ++ forbids declaration of 'mysql _ res' with no type
Qmysql. h: 26: Error: Expected '; 'before' *' token
Make [1]: *** [game. O] Error 1
Make [1]: Leaving directory '/home/zsj/temp'

Thank you for your advice.

Reply:X86 (heavy snow)() Credit: 120 2006-6-26 10:46:11 Score: 10
 
 
?
Without such experience, we recommend that you download the source code of other mysql-used programs (such as those tools on the MySQL website) to see how the files are written.

Top
 
Reply:Eqxu (Angel Alliance)() Credit: 100 2006-6-26 11:20:29 Score: 80
 
 
?
Primary des =-I./-I/usr/local/MySQL/include/
Libs =-L/usr/lib/MySQL-lmysqlclient

You can add the above to makefile. am. Of course, other necessary items must also be added.

Top
 
Reply:Ghtsao (dark moon)() Credit: 100 2006-6-26 13:23:26 Score: 10
 
 
?
Ccflags + =-I/usr/include/MySQL
Ccflags + =-ddebug
# Ccflags + =-m

Linkopts + =-L/usr/lib/MySQL
Linkopts ++ =-lmysqlclient
Linkopts ++ =-lpthread

This part is moved to makefile. am.

Top
 
Reply:Vcclass (Montenegro old demon)() Credit: 100 2006-6-26 13:27:05 Score: 0
 
 
?
Good, hero is the hero. After adding two lines of code, it will be OK. Xie eqxu (Angel Alliance ). I have been exploring for two days, but I have not done it. This problem is solved. Good. Although I have written a few Linux projects, the MAKEFILE file that someone else (old employee) has been using is the one that can be used above. Although it can be used, make clean the header file before modifying it, make again, otherwise it will not work. I should have done it several times, but it is not ideal. We have tried automake and Autoconf over and over again. I have heard that the feature is powerful, and the feature is powerful. I want to complain again. Don't laugh: I search for information on Chinese websites. Everyone is the same. If you copy my information, I copy yours, and no one will deepen it, for example, when making makefile files, everyone is "hello" and all are from the same person. It's hard to read English. No wonder the Chinese software industry is too far away from foreigners. It is estimated that the difference is far from that in India. There is really little first-hand information we can get. I don't know if you feel the same way. Either way, two words: "Close Up ".

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.