mysql icon indicating copy to clipboard operation
mysql copied to clipboard

mysql_config not found on windows

Open eflister opened this issue 12 years ago • 18 comments

i can 'mingw-get install msys-perl', which lets me 'perl "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql_config.pl"' , or even just 'mysql_config.pl', but not just 'mysql_config'

so cabal install gives:

Linking .\dist\setup\setup.exe ... Configuring mysql-0.1.1.4... setup.exe: The program mysql_config is required but it could not be found cabal: Error: some packages failed to install: mysql-0.1.1.4 failed during the configure step. The exception was: ExitFailure 1

but if i change the argument of findProgramLocation in Setup to 'mysql_config.pl', i get:

Configuring mysql-0.1.1.4... setup.exe: c:\Program Files\MySQL\MySQL Server 5.5\bin\mysql_config.pl: invalid argument cabal.exe: Error: some packages failed to install: mysql-0.1.1.4 failed during the configure step. The exception was: ExitFailure 1

$ mysql_config.pl Usage: /c/Program Files/MySQL/MySQL Server 5.5/bin/mysql_config.pl [OPTIONS] Options: --cflags ["-I/c/Program Files/MySQL/MySQL Server 5.5/include/mys ql" "/MT" "/Zi" "/O2" "/Ob1" "/D" "NDEBUG" "-DDBUG_OFF"] --include ["-I/c/Program Files/MySQL/MySQL Server 5.5/include/mys ql"] --libs ["-L/c/Program Files/MySQL/MySQL Server 5.5/lib" "-lmys qlclient" "ws2_32 Secur32 "] --libs_r ["-L/c/Program Files/MySQL/MySQL Server 5.5/lib" "-lmys qlclient_r" "ws2_32 "] --socket [/tmp/mysql.sock] --port [0] --version [5.5.28] --libmysqld-libs ["-L/c/Program Files/MySQL/MySQL Server 5.5/lib" "-lmys qld" "ws2_32 "]

eflister avatar Oct 13 '12 10:10 eflister

see also https://github.com/bos/hdbc-mysql/issues/5

eflister avatar Oct 13 '12 10:10 eflister

i can hardcode

let include = ["-I/c/Program Files/MySQL/MySQL Server 5.5/include/mysql"] libs = ["-L/c/Program Files/MySQL/MySQL Server 5.5/lib", "-lmysqlclient", "ws2_32 Secur32 "]

and then

$ cabal install --extra-lib-dirs="C:\Program Files\MySQL\MySQL Server 5.5\lib" --extra-include-dirs="C:\Program Files\MySQL\MySQL Server 5.5\include"

Resolving dependencies... Configuring mysql-0.1.1.4... Building mysql-0.1.1.4... Preprocessing library mysql-0.1.1.4... In file included from C:\Program Files\MySQL\MySQL Server 5.5\include/mysql.h:72 :0, from include/mysql_signals.h:9, from Database\MySQL\Base\C.hsc:68: C:\Program Files\MySQL\MySQL Server 5.5\include/mysql_com.h:291:3: error: expect ed specifier-qualifier-list before 'SOCKET' C:\Program Files\MySQL\MySQL Server 5.5\include/mysql_com.h:470:26: error: expec ted ')' before 's' compiling dist\build\Database\MySQL\Base\C_hsc_make.c failed (exit code 1)

if i switch to mysql 5.6

$ perl "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql_config.pl" Usage: C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql_config.pl [OPTIONS] Options: --cflags ["-I./include" "/MT" "/Zi" "/O2" "/Ob1" "/D" "NDEBUG" " /EHsc" "-DDBUG_OFF"] --cxxflags ["-I./include" "/MT" "/Zi" "/O2" "/Ob1" "/D" "NDEBUG" " /EHsc" "-DDBUG_OFF"] --include ["-I./include"] --libs ["-LC:/Program Files/MySQL/lib" "-lmysqlclient" "ws2_32 Secur32 "] --libs_r ["-LC:/Program Files/MySQL/lib" "-lmysqlclient_r" "ws2_ 32 "] --socket [/tmp/mysql.sock] --port [0] --version [5.6.7-rc] --libmysqld-libs ["-LC:/Program Files/MySQL/lib" "-lmysqld" "ws2_32 "]

after copying those include/libs into Setup,

$ cabal install --extra-lib-dirs="C:\Program Files\MySQL\MySQL Server 5.6\lib" --extra-include-dirs="C:\Program Files\MySQL\MySQL Server 5.6\include"

Resolving dependencies... [1 of 1] Compiling Main ( Setup.lhs, dist\setup\Main.o ) Linking .\dist\setup\setup.exe ... Configuring mysql-0.1.1.4... Building mysql-0.1.1.4... Preprocessing library mysql-0.1.1.4... In file included from C:\Program Files\MySQL\MySQL Server 5.6\include/mysql.h:72 :0, from ./include/mysql_signals.h:9, from Database\MySQL\Base\C.hsc:68: C:\Program Files\MySQL\MySQL Server 5.6\include/mysql_com.h:315:3: error: expect ed specifier-qualifier-list before 'SOCKET' compiling dist\build\Database\MySQL\Base\C_hsc_make.c failed (exit code 1)

so i commented out line 315 in mysql_com.h, and then:

$ cabal install --extra-lib-dirs="C:\Program Files\MySQL\MySQL Server 5.6\lib" --extra-include-dirs="C:\Program Files\MySQL\MySQL Server 5.6\include" Resolving dependencies... Configuring mysql-0.1.1.4... Building mysql-0.1.1.4... Preprocessing library mysql-0.1.1.4... [1 of 3] Compiling Database.MySQL.Base.Types ( dist\build\Database\MySQL\Base\Ty pes.hs, dist\build\Database\MySQL\Base\Types.o ) [2 of 3] Compiling Database.MySQL.Base.C ( dist\build\Database\MySQL\Base\C.hs, dist\build\Database\MySQL\Base\C.o ) [3 of 3] Compiling Database.MySQL.Base ( Database\MySQL\Base.hs, dist\build\Data base\MySQL\Base.o ) cbits\mysql_signals.c: In function 'init_rts_sigset':

cbits\mysql_signals.c:20:2: warning: implicit declaration of function 'sigemptyset'

cbits\mysql_signals.c:21:2: warning: implicit declaration of function 'sigaddset'

cbits\mysql_signals.c:21:18: error: 'SIGALRM' undeclared (first use in this function)

cbits\mysql_signals.c:21:18: note: each undeclared identifier is reported only once for each function it appears in

cbits\mysql_signals.c:22:18: error: 'SIGVTALRM' undeclared (first use in this function) cbits\mysql_signals.c: In function '_hs_mysql_real_connect':

cbits\mysql_signals.c:45:5: warning: implicit declaration of function 'pthread_sigmask' cabal.exe: Error: some packages failed to install: mysql-0.1.1.4 failed during the building phase. The exception was: ExitFailure 1

so i commented out lines 21 and 22 in mysql_signals.c, and then finally!

$ cabal install --extra-lib-dirs="C:\Program Files\MySQL\MySQL Server 5.6\lib" --extra-include-dirs="C:\Program Files\MySQL\MySQL Server 5.6\include" Resolving dependencies... Configuring mysql-0.1.1.4... Building mysql-0.1.1.4... Preprocessing library mysql-0.1.1.4... cbits\mysql_signals.c: In function 'init_rts_sigset':

cbits\mysql_signals.c:20:2: warning: implicit declaration of function 'sigemptyset' cbits\mysql_signals.c: In function '_hs_mysql_real_connect':

cbits\mysql_signals.c:45:5: warning: implicit declaration of function 'pthread_sigmask' Warning: resolving __hs_mysql_close by linking to __hs_mysql_close@4 Use --enable-stdcall-fixup to disable these warnings Use --disable-stdcall-fixup to disable these fixups Warning: resolving __hs_mysql_real_connect by linking to __hs_mysql_real_connect @32 Warning: resolving __hs_mysql_next_result by linking to __hs_mysql_next_result@4

Warning: resolving __hs_mysql_ping by linking to __hs_mysql_ping@4 Warning: resolving __hs_mysql_autocommit by linking to __hs_mysql_autocommit@8 Warning: resolving __hs_mysql_change_user by linking to __hs_mysql_change_user@1 6 Warning: resolving __hs_mysql_select_db by linking to __hs_mysql_select_db@8 Warning: resolving __hs_mysql_real_query by linking to __hs_mysql_real_query@12 Warning: resolving __hs_mysql_commit by linking to __hs_mysql_commit@4 Warning: resolving __hs_mysql_rollback by linking to __hs_mysql_rollback@4 Warning: resolving __hs_mysql_stat by linking to __hs_mysql_stat@4 Warning: resolving __hs_mysql_store_result by linking to __hs_mysql_store_result @4 Warning: resolving __hs_mysql_use_result by linking to __hs_mysql_use_result@4 Warning: resolving __hs_mysql_free_result by linking to __hs_mysql_free_result@4

Warning: resolving __hs_mysql_fetch_row by linking to __hs_mysql_fetch_row@4 Registering mysql-0.1.1.4... Installing library in C:\Users\nlab\AppData\Roaming\cabal\mysql-0.1.1.4\ghc-7.4.1 Registering mysql-0.1.1.4...

whew!

eflister avatar Oct 13 '12 11:10 eflister

but then, when i try to install something that uses it:

$ cabal install --extra-lib-dirs="C:\Program Files\MySQL\MySQL Server 5.6\lib" --extra-include-dirs="C:\Program Files\MySQL\MySQL Server 5.6\include"

Resolving dependencies... Configuring widefield-0.0.0... Building widefield-0.0.0... Preprocessing library widefield-0.0.0... [1 of 8] Compiling Settings.Development ( Settings\Development.hs, dist\build\Se ttings\Development.o ) [2 of 8] Compiling Model ( Model.hs, dist\build\Model.o ) Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. ... Loading package mysql-0.1.1.4 ... ghc.exe: mysqlclient: The specified module cou ld not be found. : can't load .so/.DLL for: mysqlclient.dll (addDLL: could not load DLL) cabal.exe: Error: some packages failed to install: widefield-0.0.0 failed during the building phase. The exception was: ExitFailure 1

note there is a .lib, not a .dll, by that name:

$ ls -al "C:\Program Files\MySQL\MySQL Server 5.6\lib" total 17143 drwxr-xr-x 4 nlab Administrators 0 Oct 13 02:25 . drwxr-xr-x 7 nlab Administrators 4096 Oct 13 02:25 .. drwxr-xr-x 2 nlab Administrators 0 Oct 13 02:25 debug -rwxr-xr-x 1 nlab Administrators 4752384 Sep 19 01:40 libmysql.dll -rw-r--r-- 1 nlab Administrators 24322 Sep 19 01:40 libmysql.lib -rw-r--r-- 1 nlab Administrators 12769090 Sep 19 01:38 mysqlclient.lib drwxr-xr-x 2 nlab Administrators 4096 Oct 13 02:25 plugin

eflister avatar Oct 13 '12 11:10 eflister

if i follow the advice here, to copy libmysql.dll to mysqlclient.dll: http://www.haskell.org/pipermail/haskell-cafe/2009-June/063150.html

i get:

... Loading package mysql-0.1.1.4 ... ghc.exe: C:\Program Files\MySQL\MySQL Server 5 .6\lib\mysqlclient: %1 is not a valid Win32 application. : can't load .so/.DLL for: C:\Program Files\MySQL\MySQL Server 5.6 \lib\mysqlclient.dll (addDLL: could not load DLL) cabal: Error: some packages failed to install: widefield-0.0.0 failed during the building phase. The exception was: ExitFailure 1

eflister avatar Oct 13 '12 12:10 eflister

I have managed to install mysql by modifying Setup.hs to run perl with the mysql_config.pl script. I have also changed the mysql_signals.c file to comment out the posix specific lines that don't work on windows. I can then build and install mysql and mysql-simple also passing extra-include-dirs and extra-lib-dirs, but any attempt to build code using them fails:

c:\Users\jpmoresmau\Mes documents\myproj\./.dist-buildwrapper/ca
bal-dev//lib\mysql-simple-0.2.2.4/ghc-7.4.2/libHSmysql-simple-0.2.2.4.a(Simple.o
):fake:(.text+0x44c7): undefined reference to `mysql_affected_rows'
c:\Users\jpmoresmau\Mes documents\myproj\./.dist-buildwrapper/ca
bal-dev//lib\mysql-simple-0.2.2.4/ghc-7.4.2/libHSmysql-simple-0.2.2.4.a(Simple.o
):fake:(.text+0x45b6): undefined reference to `mysql_field_count'

And a lot more. Any ideas? I need to connect to MySql via Haskell and I run on windows, it's a bit depressing to see Unix-only haskell bindings...

JPMoresmau avatar Mar 28 '13 21:03 JPMoresmau

When I add extra-libraries:mysql to the mysql Cabal file, the undefined reference to mysql_* disappear, but undefined references to hs* remain. I suspect maybe an issue with calling conventions under MINGW? When I change the code in C.hsc to use stdcall, mysql build properly, but then my project that uses mysql-simple does not find it anymore, even though I reinstalled it and install-deps tells me everything is up to date, it seems the hash is not generated in the same way. I'm a bit lost on what I can do now. I'll be happy to do more tests. So I have a project that uses mysql-simple on top of mysql. I have Mingw on Windows 8.

JPMoresmau avatar Mar 29 '13 14:03 JPMoresmau

Sorry for the constant updates, but at least there'll be a trace. I've force the removal of stdcall in mysql.h and I can get my executable to compile successfully! It now crashes while trying to connect. There's probably a worry with the libmysql.dll file...

JPMoresmau avatar Mar 29 '13 17:03 JPMoresmau

Hi, I have the same problem with mysql-0.1.1.6

C:\Users\Ruru>cabal install mysql Resolving dependencies... [1 of 1] Compiling Main ( C:\Users\Ruru\AppData\Local\Temp\mysql-0.1.1.6-8828\mysql-0.1.1.6\Setup.lhs, C:\Users\Ruru\AppData\Local\Temp\mysql-0.1.1.6-8828\mysql-0.1.1.6\dist\setup\Main.o ) Linking C:\Users\Ruru\AppData\Local\Temp\mysql-0.1.1.6-8828\mysql-0.1.1.6\dist\setup\setup.exe ... Configuring mysql-0.1.1.6... setup.exe: The program mysql_config is required but it could not be found Failed to install mysql-0.1.1.6 cabal: Error: some packages failed to install: mysql-0.1.1.6 failed during the configure step. The exception was: ExitFailure 1

Environment Description

Windows 7 x64 Mysql 5.6.21

Path = C:\Program Files\Haskell Platform\2014.2.0.0\mingw\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin;C:\Users\Ruru\AppData\Roaming\cabal\bin;C:\Program1\Android\android-sdk\platform-tools;C:\Program Files (x86)\MySQL\MySQL Server 5.6\lib

KroshkaRu avatar Sep 25 '14 16:09 KroshkaRu

I have hardcoded path. There are two tries extraLibDirs = ["C:/Program Files (x86)/MySQL/MySQL Server 5.6/lib"] , extraLibs = ["mysqlclient.lib", "pthread", "z","m","dl"] , includeDirs = ["C:/Program Files (x86)/MySQL/MySQL Server 5.6/include/mysql"]

or extraLibDirs = ["C:/Program Files (x86)/MySQL/MySQL Connector.C 6.1/lib","C:/Program Files (x86)/MySQL/MySQL Connector.C 6.1/lib/vs10" ] , extraLibs = ["mysqlclient.lib", "pthread", "z","m","dl"] , includeDirs = ["C:/Program Files (x86)/MySQL/MySQL Connector.C 6.1/include", "C:/Program Files (x86)/MySQL/MySQL Connector.C 6.1/include/mysql"]

the result in both cases is Configuring mysql-0.1.1.6... Setup: Missing dependencies on foreign libraries:

  • Missing C libraries: mysqlclient.lib, z, dl This problem can usually be solved by installing the system packages that provide these libraries (you may need the "-dev" versions). If the libraries are already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.

KroshkaRu avatar Sep 26 '14 12:09 KroshkaRu

Is there any workaround for this? I've tried adding perl to PATH, which doesn't really help since the file can't be found, and modifying Setup.hs to contain perl mysql_config.pl doesn't find it as well, so I tried coyping over mysql_config.pl to the directory (of the mysql package), but even just running perl mysql_config.pl fails with

Can't locate File/Basename.pm in @INC (@INC contains: C:/Program Files/Haskell Platform/2014.2.0.0/lib .) at mysql_config.pl line 39.

darthdeus avatar Feb 07 '15 22:02 darthdeus

I've managed to work around this issue by installing strawberryperl and directly modifying the Setup.lhs to run perl with mysql_config.pl as an argument explicitly. This however still fails with the following error

Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring mysql-0.1.1.7...
Building mysql-0.1.1.7...
Preprocessing library mysql-0.1.1.7...
In file included from C.hsc:68:0:
include/mysql_signals.h:9:19: fatal error: mysql.h: No such file or directory
compilation terminated.
compiling dist\build\Database\MySQL\Base\C_hsc_make.c failed (exit code 1)
command was: C:\Program Files\Haskell Platform\2014.2.0.0\mingw\bin\gcc.exe -c dist\build\Database\MySQL\Base\C_hsc_make
.c -o dist\build\Database\MySQL\Base\C_hsc_make.o -D__GLASGOW_HASKELL__=708 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -
Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Iinclude -Idist\build\autogen -include dist\build\autogen\cabal_macros.h -IC:\P
rogram Files\Haskell Platform\2014.2.0.0\lib\bytestring-0.10.4.0\include -Idist\build\autogen -include dist\build\autoge
n\cabal_macros.h -Idist\build\autogen -include dist\build\autogen\cabal_macros.h -Idist\build\autogen -include dist\buil
d\autogen\cabal_macros.h -IC:\Program Files\Haskell Platform\2014.2.0.0\lib\base-4.7.0.1\include -Idist\build\autogen -i
nclude dist\build\autogen\cabal_macros.h -IC:\Program Files\Haskell Platform\2014.2.0.0\lib\integer-gmp-0.5.1.0\include
-Idist\build\autogen -include dist\build\autogen\cabal_macros.h -Idist\build\autogen -include dist\build\autogen\cabal_m
acros.h -IC:\Program Files\Haskell Platform\2014.2.0.0\lib/include -Idist\build\autogen -include dist\build\autogen\caba
l_macros.h -IC:\Program Files\Haskell Platform\2014.2.0.0/lib/include/

darthdeus avatar Feb 08 '15 00:02 darthdeus

and after building with cabal install --extra-include-dirs=PATH_TO_MYSQL_INCLUDE this still fails with

Preprocessing library mysql-0.1.1.7...
In file included from C:\Program Files\MySQL\MySQL Server 5.6\include/mysql.h:72:0,
                 from include/mysql_signals.h:9,
                 from C.hsc:68:
C:\Program Files\MySQL\MySQL Server 5.6\include/mysql_com.h:320:3: error: unknown type name 'SOCKET'
compiling dist\build\Database\MySQL\Base\C_hsc_make.c failed (exit code 1)
command was: C:\Program Files\Haskell Platform\2014.2.0.0\mingw\bin\gcc.exe -c dist\build\Database\MySQL\Base\C_hsc_make
.c -o dist\build\Database\MySQL\Base\C_hsc_make.o -D__GLASGOW_HASKELL__=708 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -
Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Iinclude -I"C:\Program -IFiles\MySQL\MySQL -IServer -I5.6\include" -IC:\Program
 Files\MySQL\MySQL Server 5.6\include -Idist\build\autogen -include dist\build\autogen\cabal_macros.h -IC:\Program Files
\Haskell Platform\2014.2.0.0\lib\bytestring-0.10.4.0\include -Idist\build\autogen -include dist\build\autogen\cabal_macr
os.h -Idist\build\autogen -include dist\build\autogen\cabal_macros.h -Idist\build\autogen -include dist\build\autogen\ca
bal_macros.h -IC:\Program Files\Haskell Platform\2014.2.0.0\lib\base-4.7.0.1\include -Idist\build\autogen -include dist\
build\autogen\cabal_macros.h -IC:\Program Files\Haskell Platform\2014.2.0.0\lib\integer-gmp-0.5.1.0\include -Idist\build
\autogen -include dist\build\autogen\cabal_macros.h -Idist\build\autogen -include dist\build\autogen\cabal_macros.h -IC:
\Program Files\Haskell Platform\2014.2.0.0\lib/include -Idist\build\autogen -include dist\build\autogen\cabal_macros.h -
IC:\Program Files\Haskell Platform\2014.2.0.0/lib/include/
cabal: Error: some packages failed to install:
mysql-0.1.1.7 failed during the building phase. The exception was:
ExitFailure 1

I guess this problem runs deeper than first seemed

darthdeus avatar Feb 08 '15 00:02 darthdeus

Ok so I've managed to get this to build, similarly to what @eflister says.

  1. comment out line 320 in mysql_com.h in the MySQL includes dir
  2. comment out lines 22 and 23 in mysql_signals.c in the cbits dir in this repo
  3. add the following definition to the same file on line 9, just before static sigset_t sigs[1]; is.
typedef struct {        /* signal set type */
    unsigned long   __sigbits[4];
} sigset_t;

Following all of this, I could then install with

C:\Users\Jakub\Documents\mysql-0.1.1.7>cabal install --extra-include-dirs="C:\Program Files\MySQL\MySQL Server 5.6\include" --extra-lib-dirs="C:\Program Files\MySQL\MySQL Server 5.6\lib"

darthdeus avatar Feb 08 '15 01:02 darthdeus

Just a minor update for those who end up finding this issue. I managed to get my app working by replacing the mysql package with ODBC altogether (specifically persistent-odbc), which compiles and works without any issues on Windows.

darthdeus avatar Feb 11 '15 17:02 darthdeus

@darthdeus I am trying to make up everything using stack, because I am following the yesod quickstart page (http://www.yesodweb.com/page/quickstart). I have used these commands:

stack new my-project yesod-mysql && cd my-project stack install yesod-bin cabal-install --install-ghc stack build

in the last one I get the following message:

Process exited with code: ExitFailure 1
Logs have been written to: C:\msys64\project\my-project\.stack-work\logs\mysql-0.1.1.8.log

[1 of 1] Compiling Main             ( C:\msys64\tmp\stack5708\mysql-0.1.1.8\Setup.lhs, C:\msys64\tmp\stack5708\mysql-0.1.1.8\.stack-work\dist\2672c1f3\setup\Main.o )
Linking C:\msys64\tmp\stack5708\mysql-0.1.1.8\.stack-work\dist\2672c1f3\setup\setup.exe ...
Configuring mysql-0.1.1.8...
setup.exe: The program 'mysql_config' is required but it could not be found

How can I make what you said in this situation "I managed to get my app working by replacing the mysql package with ODBC altogether (specifically persistent-odbc)"

As you see I am a beginner in Yesod, so please, try to explain detailed...

felipexpert avatar Feb 17 '16 22:02 felipexpert

@felipexpert I had this issue in mac os and stack too, and I fixed by just making available in the console the program 'mysql_config' which was located in '/usr/local/mysql/bin'. Maybe that is what you can do in windows to fix that.

carliros avatar Apr 22 '16 11:04 carliros

Thank you for communicating.

On Fri, Apr 22, 2016 at 8:50 AM, Carlos Gómez [email protected] wrote:

@felipexpert https://github.com/felipexpert I had this issue in mac os and stack too, and I fixed by just making available in the console the program 'mysql_config' which was located in '/usr/local/mysql/bin'. Maybe that is what you can do in windows to fix that.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/bos/mysql/issues/3#issuecomment-213391797

Felipe Carmona Miquilini

felipexpert avatar Apr 23 '16 00:04 felipexpert

Encountered this problem on Ubuntu and solved with this

sudo apt-get install libmysqlclient-dev

Vozf avatar May 17 '19 11:05 Vozf