'Makefile.PL'에 해당되는 글 1건

  1. 2008/08/29 DBD::mysql 모듈 설치
perl에서 데이터베이스 접근을 위한 모듈을 설치한다.
사용자는 DBI모듈 불러오고 이 DBI모듈이 DBD::mysql 모듈을 불러와 DB에 접근할 수 있다.

모듈정보를 확인한다.

# perl -MDBI -e 'print "$DBI::VERSION\n"'
Can't locate DBI.pm in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.8.6/mach /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.6/BSDPAN /usr/local/lib/perl5/5.8.6/mach /usr/local/lib/perl5/5.8.6 .).
BEGIN failed--compilation aborted.

# perl -MDBD::mysql -e 'print "$DBD::mysql::VERSION\n"'
Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.8.6/mach /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.6/BSDPAN /usr/local/lib/perl5/5.8.6/mach /usr/local/lib/perl5/5.8.6 .).
BEGIN failed--compilation aborted.

# cpan
cpan> i /DBI/
cpan> install DBI
cpan> exit
# perl -MDBI -e 'print "$DBI::VERSION\n"'
1.607

DBI 모듈이 설치되었다.

DBD::mysql 모듈을 설치한다.

# cpan
cpan> install DBD::mysql
...
mysql_config 를 찾지못한다고 오류가나면서 종료된다.
$PATH를 추가하고 다시 한다.

이번에는 DB 테스트하는 과정에서 오류가 난다.
테스트를 건너뛰고 모듈을 설치할 수도 있겠지만 어떻게 하는지는 모르겠다.
기본 DB가 test인데 내가 가지고 있는 mysql 서버에는 test DB조차 없다.
root 계정도 비밀번호가 있어서 어쨌든 DB 테스트는 실패로 끝났다.

$HOME/.cpan/ 디렉토리의 설치문서를 본다.

$ vi /root/.cpan/build/DBD-mysql-4.008/INSTALL.html

이런 부분이 있다.

CPAN installation

.....
If you cannot get the CPAN module working, you might try manual installation. If installation with CPAN fails because the your local settings have been guessed wrong, you need to ensure MySQL's mysql_config is on your path (see SOURCE INSTALLATION) or alternatively create a script called mysql_config. This is described in more details later. Configuration.
....

또 이런 부분도 있다.

Configuration

The install script ``Makefile.PL'' can be configured via a lot of switches. All switches can be used on the command line. For example, the test database:

  perl Makefile.PL --testdb=<db>

If you do not like configuring these switches on the command line, you may alternatively create a script called mysql_config. This is described later on.

Available switches are:

testdb

   Name of the test database, defaults to test.

testuser

   Name of the test user, defaults to empty. If the name is empty, then the currently logged in users name will be used.

testpassword

   Password of the test user, defaults to empty.

testhost

   Host name or IP number of the test database; defaults to localhost.

testport

   Port number of the test database

ps-protcol=1 or 0

   Whether to run the test suite using server prepared statements or driver emulated prepared statemetns. ps-protocol=1 means use server prepare, ps-protocol=0 means driver emulated.

cflags

   This is a list of flags that you want to give to the C compiler. The most important flag is the location of the MySQL header files. For example, on Red Hat Linux the header files are in /usr/include/mysql and you might try

     -I/usr/include/mysql

   On Windows the header files may be in C:\mysql\include and you might try

     -IC:\mysql\include

   The default flags are determined by running

     mysql_config --cflags

   More details on the C compiler flags can be found in the following section. Compiler flags.

libs

   This is a list of flags that you want to give to the linker or loader. The most important flags are the locations and names of additional libraries. For example, on Red Hat Linux your MySQL client libraries are in /usr/lib/mysql and you might try

     -L/usr/lib/mysql -lmysqlclient -lz

   On Windows the libraries may be in C:\mysql\lib and

     -LC:\mysql\lib -lmysqlclient

   might be a good choice. The default flags are determined by running

     mysql_config --libs

   More details on the linker flags can be found in a separate section. Linker flags.

If a switch is not present on the command line, then the script mysql_config will be executed. This script comes as part of the MySQL distribution. For example, to determine the C compiler flags, we are executing

  mysql_config --cflags
  mysql_config --libs

If you want to configure your own settings for database name, database user and so on, then you have to create a script with the same name, that replies

 
=head2 Compiler flags

Note: the folling info about compiler and linker flags, you shouldn't have to use these options because Makefile.PL is pretty good at utilising mysql_config to get the flags that you need for a successful compile.

It is typically not so difficult to determine the appropriate flags for the C compiler. The linker flags, which you find in the next section, are another story.

The determination of the C compiler flags is usually left to a configuration script called mysql_config, which can be invoked with

  mysql_config --cflags

When doing so, it will emit a line with suggested C compiler flags, for example like this:

  -L/usr/include/mysql

The C compiler must find some header files. Header files have the extension .h. MySQL header files are, for example, mysql.h and mysql_version.h. In most cases the header files are not installed by default. For example, on Windows it is an installation option of the MySQL setup program (Custom installation), whether the header files are installed or not. On Red Hat Linux, you need to install an RPM archive mysql-devel or MySQL-devel.

If you know the location of the header files, then you will need to add an option

  -L<header directory>

to the C compiler flags, for example -L/usr/include/mysql.


# cd ~/.cpan/build/DBD-mysql-4.008
# perl Makefile.PL --testdb=xxxx --testuser=xxxx --testpassword=xxxx --testhost=localost
# make
# make test
테스트할때 중간쯤 오래걸릴때가 있다. 그럴땐 가볍게 Ctrl-C..

# make install
# perl -MDBD::mysql -e 'print "$DBD::mysql::VERSION\n"'
4.008

운영체제는 FreeBSD 5.4 이고 perl 버전은 5.8.6, mysql 버전은 4.1.18 이다.