Trying to build mysql-connector-cpp on Windows

空扰寡人 提交于 2019-12-24 07:59:09

问题


I want to be able to build mysql-connector/c++ applications in debug mode (VS2k17), and understand the only way I can do that is to first build mysql-connector-cpp from source on my computer (Windows 10/64bit). I tried the following:

cmake . -DWITH_SSL=C:\Users\Rawb\source\libraries\OpenSSL-Win64

and it looks to complete successfully ...

Install location: C:/Users/Rawb/MySQL/MySQL Connector C++ 8.0
Connector libraries will be installed at: lib
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Rawb/source/repos/mcc2/mysql-connector-cpp

but when I run the following cmake build ...

cmake --build . --config

it fails with this output ...

LINK : fatal error LNK1104: cannot open file 'ssleay32.lib' [C:\Users\Rawb\source\repos\mcc2\mysql-connector-cpp\connector.vcxproj]
Done Building Project "C:\Users\Rawb\source\repos\mcc2\mysql-connector-cpp\connector.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\Rawb\source\repos\mcc2\mysql-connector-cpp\ALL_BUILD.vcxproj" (default targets) -- FAILED.
Build FAILED.

"C:\Users\Rawb\source\repos\mcc2\mysql-connector-cpp\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\Rawb\source\repos\mcc2\mysql-connector-cpp\connector.vcxproj" (default target) (10) ->
(Link target) ->
LINK : fatal error LNK1104: cannot open file 'ssleay32.lib' [C:\Users\Rawb\source\repos\mcc2\mysql-connector-cpp\connector.vcxproj]
0 Warning(s)
1 Error(s)

Time Elapsed 00:00:14.57

What might I be doing wrong? Do I just need to place the ssleay32.lib file somewhere? I do have a copy of it but not sure how it should be included. Or is it more complex? I.e. Do I need to build Open SSL first on my machine as well? This is a deep rabbit hole for me, I may be in over my head haha!

NOTE: I also asked this question on reddit with no luck, so hoping someone here might know.


回答1:


  1. If you're using MSVS (any version, including MSVS 2017), then I'd suggest using "NMake" (instead of cmake). Or just create a new C/C++ library project in the MSVS IDE.

  2. The flag you're looking for is /LIBPATH. I don't think you need "-D", but you certainly need "/LIBPATH".

    Here are the MSVS linker options:

    https://docs.microsoft.com/en-us/cpp/build/reference/linker-options?view=vs-2017

  3. Finally, you might be able to do all the troubleshooting/tracing you want without actually debugging (and rebuilding) the connector code.

    Here's how to enable tracing in the MySQL Connector:

    https://dev.mysql.com/doc/connector-cpp/1.1/en/connector-cpp-debug-tracing.html

Please let me know if this helps.



来源:https://stackoverflow.com/questions/54857347/trying-to-build-mysql-connector-cpp-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!