Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install issues on Windows Server 2022 - undefined references #455

Open
geekdad1 opened this issue Dec 16, 2024 · 5 comments
Open

Install issues on Windows Server 2022 - undefined references #455

geekdad1 opened this issue Dec 16, 2024 · 5 comments
Assignees

Comments

@geekdad1
Copy link

DBD::mysql version

5.010

MySQL client version

No response

Server version

Windows server 2022

Operating system version

Server 2022

What happened?

Trying to create a mysql client on a server that does not have mysql installed on it. I've copied the lib and include folders from the server and put them on this machine so that the installation will at last compile.
I'm using the following command to create the makefile:

`perl MakeFile1.pl --cflags="-Ic:\mysql\install\include -Lc:\mysql\install\lib -lmysqlclient" --mysql_config=c:\mysql\install --libs=-Lc:\mysql\install\lib

when I run gmake I get the following (shortened) result. So I'm not sure what else I'm missing. Any help is appreciated.

"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- mysql.bs blib\arch\auto\DBD\mysql\mysql.bs 644
g++ mysql.def -o blib\arch\auto\DBD\mysql\mysql.xs.dll -shared -s -L"C:\STRAWBERRY\perl\lib\CORE" -L"C:\STRAWBERRY\c\lib" -L"C:\STRAWBERRY\c\x86_64-w64-mingw32\lib" -L"C:\STRAWBERRY\c\lib\gcc\x86_64-w64-mingw32\13.2.0" dbdimp.o mysql.o socket.o "C:\STRAWBERRY\perl\lib\CORE\libperl540.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libmoldname.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libkernel32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libuser32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libgdi32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libwinspool.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libcomdlg32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libadvapi32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libshell32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libole32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\liboleaut32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libnetapi32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libuuid.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libws2_32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libmpr.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libwinmm.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libversion.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libodbc32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libodbccp32.a" "C:\STRAWBERRY\c\x86_64-w64-mingw32\lib\libcomctl32.a" -Wl,--enable-auto-image-base
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: dbdimp.o: in function mysql_dr_connect': C:/Perl64/cpan/build/DBD-mysql-5.010-0/dbdimp.c:1208:(.text+0xa74): undefined reference to mysql_server_init'
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Perl64/cpan/build/DBD-mysql-5.010-0/dbdimp.c:1209:(.text+0xa81): undefined reference to mysql_init' C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Perl64/cpan/build/DBD-mysql-5.010-0/dbdimp.c:1231:(.text+0xb48): undefined reference to mysql_options'
,,,

`

Other information

No response

@dveeden
Copy link
Collaborator

dveeden commented Dec 16, 2024

What versions of Perl, DBD::mysql, MySQL, etc are you using?
Copying lib and include might not be sufficient and might also run into issues if Perl and MySQL aren't using the same compiler, the same compiler version and the same compiler options.

There is some info on https://dev.mysql.com/doc/c-api/8.4/en/c-api-building-clients.html that might be useful

@geekdad1
Copy link
Author

geekdad1 commented Dec 17, 2024 via email

@dveeden
Copy link
Collaborator

dveeden commented Dec 17, 2024

On Linux and most other systems mysql_config is a tool that is part of the MySQL development installation and returns the flags that should be used to compile programs that use MySQL.

$ mysql_config
Usage: /usr/bin/mysql_config-64 [OPTIONS]
Compiler: GNU 14.2.1
Options:
        --cflags         [-I/usr/include/mysql -m64 ]
        --cxxflags       [-I/usr/include/mysql -m64 ]
        --include        [-I/usr/include/mysql]
        --libs           [-L/usr/lib64/mysql -lmysqlclient -lz  -lssl  -lcrypto -lresolv -lm]
        --libs_r         [-L/usr/lib64/mysql -lmysqlclient -lz  -lssl  -lcrypto -lresolv -lm]
        --plugindir      [/usr/lib64/mysql/plugin]
        --socket         [/var/lib/mysql/mysql.sock]
        --port           [0]
        --version        [9.1.0]
        --variable=VAR   VAR is one of:
                pkgincludedir [/usr/include/mysql]
                pkglibdir     [/usr/lib64/mysql]
                plugindir     [/usr/lib64/mysql/plugin]
$ mysql_config --cflags --libs
-I/usr/include/mysql -m64 
-L/usr/lib64/mysql -lmysqlclient -lz  -lssl  -lcrypto -lresolv -lm
$ rpm -qf $(which mysql_config)
mysql-community-devel-9.1.0-10.fc41.x86_64

On Windows mysql_config is not part of MySQL, but is a simple batch file that Strawberry Perl ships to allow you to compile things against the MySQL client library that it ships.

However the MySQL client library that Strawberry Perl ships is based on MySQL 5.7.x last time I checked and MySQL 5.7 is EOL and too old for recent versions of DBD::mysql. It will probably work with the last v4.x version of DBD::mysql.

The file is here: https://github.com/StrawberryPerl/build-extlibs/blob/master/mysql.special/mysql_config.bat

@dveeden
Copy link
Collaborator

dveeden commented Dec 17, 2024

@geekdad1 could you have a look at this and see if that helps to get a working DBD::mysql installation?

@geekdad1
Copy link
Author

That link was a great help. having a mysql_config.bat file went a long way toward solving the problem.

The other steps was I copied the mysql/lib and mysql/include folders off the server and put them on this server which got me through the compile errors. You need to run perl MakeFile.PL --mysql_config=c:\folderpath
to get that to work.
Lastly I had to copy the libmysql.dll to the c:\strawberry\c\bin folder in order to resolve a loader error when trying to connect to a database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants