Mysql Static Dll
On Windows, the static library is named mysqlclient.lib and the dynamic library is named libmysql.dll. In addition, the libmysql.lib static import library is needed.
My project is running fine, but its requirement for some DLLs means it cannot be simply dragged and dropped by the end user. The DLLs are not loaded when put side by side with my executable, because my executable is not an application, and its location is not in the few locations where Windows looks for DLL. I already asked a question about how to make their loading happen. None of the suggestions worked (see the question at ) So I am now exploring another way: get rid of the DLLs altogether, and link with static versions of them. This is failing for the last of those DLLs.
So I am at this point where all but one of the libraries are statically linked, and everything is fine. The last library is the standard C library for mySQL, aka Connector/C. The problem I have may or may not be related with that origin. Whenever I switched to the static library in the linker additional dependency, I get the following errors (log at the end): 1- about 40 duplicate symbols (e.g. _toupper) mutually between LIBCMT.lib and MSVCRT.lib.
Interestingly, I can't control the inclusion of these two libraries: they are from Visual Studio and automatically included. So why are these symbol duplicate when I include mySQL's static lib, but not its DLL? Well, writing up my question led me to a solution. The key was the two lines: LINK: warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library LINK: warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library I found the 'Ignore specific library' in the input part of the linker section of the project properties.
Adding LIBCMT there, and only that one, fixed everything. What happened to that _main symbol? But it works.
Linking Connector/C++ to Applications Connector/C++ is available as a dynamic or static library to use with your application. This section describes how to link the library to your application. Linking the Dynamic Library To use a dynamic library file (.dll extension), link your application with a.lib import library.
At runtime, the application must have access to the.dll library. The following table indicates which import library and dynamic library files to use for Connector/C++. LIB denotes the Connector/C++ installation library path name. Ines de la fressange books.
The name of the last path component differs depending on whether you use a 64-bit or 32-bit package. The name ends with lib64/vs14 for 64-bit packages, lib/vs14 for 32-bit packages.
In addition, import library files are found in a subdirectory named for the build type used to build the libraries, here designated as vs14. Connector Type Import Library Dynamic Library X DevAPI, X DevAPI for C LIB/vs14/mysqlcppconn8.lib LIB/mysqlcppconn8-1-vs14.dll JDBC LIB/vs14/mysqlcppconn.lib LIB/mysqlcppconn-7-vs14.dll Linking the Static Library To use a static library file (.lib extension), link your application with the library. The following table indicates which static library files to use for Connector/C++. LIB denotes the Connector/C++ installation library path name.
The name of the last path component differs depending on whether you use a 64-bit or 32-bit package. The name ends with lib64 for 64-bit packages, lib for 32-bit packages. In addition, static library files are found in a subdirectory named for the build type used to build the libraries, here designated as vs14. Connector/C++ and Application Build Configuration Must Match Because the application build configuration must match that of the Connector/C++ it uses, Release is required when using an Oracle-built Connector/C++, which is built in the release configuration. When linking dynamically, it is possible to build your code in debug mode even if the connector libraries are built in release mode.
However, in that case, it will not be possible to step inside connector code during a debug session. To be able to do that, or to build in debug mode while linking statically to the connector, you must build Connector/C++ from source yourself using the Debug configuration.