You are on page 1of 3

28/03/2015

MySQL::MySQLConnector/CDeveloperGuide::5.2InstallingConnector/CfromSource

MySQLConnector/CDeveloperGuide::5InstallingConnector/C::5.2InstallingConnector/Cfrom
Source

5.2InstallingConnector/Cfrom
Source

5.1InstallingConnector/CfromaBinary
Distribution
5.3PostinstallationSteps

SectionNavigation[Toggle]

AConnector/Csourcedistributionispackagedasa
compressedtarfile,Ziparchive,orRPMpackage,denoted
hereas PACKAGE .tar.gz, PACKAGE .zip,or.
PACKAGE .src.rpm.AsourcedistributionintarfileorZip
archiveformatcanbeusedonanysupportedplatformlisted
inChapter3,Connector/CSupportedPlatforms.AnRPM
packagesourcedistributionisintendedforRPMbased
systemssuchasLinux.

5InstallingConnector/C
5.1InstallingConnector/C
fromaBinaryDistribution
5.2InstallingConnector/C
fromSource
5.3PostinstallationSteps
5.4TestingConnector/C

Toinstallacompressedtarfile,usethiscommandintheintendedinstallationdirectory:
shell> tarzxvf PACKAGE .tar.gz

Afterunpackingthedistribution,builditusingtheappropriateinstructionsforyourplatformlaterinthis
section.
TounpackaZiparchive,useWinZiporanothertoolthatcanread.zipfiles.Afterunpackingthe
distribution,builditusingtheappropriateinstructionsforyourplatformlaterinthissection.
ToinstallanRPMpackage,usethiscommandtocreatebinaryRPMpackagesthatyoucaninstall.If
youdonothaverpmbuild,userpminstead.
shell> rpmbuildrebuildclean PACKAGE .src.rpm

ThecommandshouldproducebinarysharedanddevelRPMpackagesandindicatewhereitplaced
them.YoucaninstallthesepackagesusingtheinstructionsinSection5.1,InstallingConnector/Cfrom
aBinaryDistribution.

BuildingConnector/ConUnixfromSource
Ifthenativecompilertoolsetforthetargetplatformisavailable(forexample,SunStudioforSolaris),
youcanusethatforcompilation.Alternatively,theGNUtoolsetcanbeusedonallplatforms.
YoualsoneedCMake2.6ornewer,whichisavailablefromcmake.org.
Tobuildandinstallthesourcedistribution,usethefollowingprocedure:
1. Changelocationtothetopleveldirectoryofthesourcedistribution.
2. GeneratetheMakefile:
shell> cmakeG"UnixMakefiles"

Or,foraDebugbuild:
shell> cmakeG"UnixMakefiles"DCMAKE_BUILD_TYPE=Debug

Bydefault,theinstallationlocationforConnector/Cis/usr/local/mysql.Tochangethis
location,usetheCMAKE_INSTALL_PREFIXoptiontospecifyadifferentdirectorywhengenerating
theMakefile.Forexample:
http://dev.mysql.com/doc/connectorc/en/connectorcinstallationsource.html#connectorcbuildoptions

1/3

28/03/2015

MySQL::MySQLConnector/CDeveloperGuide::5.2InstallingConnector/CfromSource

shell> cmakeG"UnixMakefiles"DCMAKE_INSTALL_PREFIX=/opt/local/mysql

ForotherCMakeoptionsthatyoumightfinduseful,seeOtherConnector/CBuildOptions.
3. Buildtheproject:
shell> make

4. Asroot,installtheConnector/Cheaders,libraries,andutilities:
rootshell> makeinstall

BuildingConnector/ConMicrosoftWindowsfromSource
Connector/CcanbebuiltonseveralversionsofMicrosoftWindows,listedinChapter3,Connector/C
SupportedPlatforms.
MicrosoftVisualStudio8or9isrecommended.TheExpressEditionofVisualStudioandother
compilersmightwork,butareuntested.
YoualsoneedCMake2.6ornewer,whichisavailablefromcmake.org.
Tobuildandinstallthesourcedistribution,usethefollowingprocedure:
1. SettheenvironmentvariablesfortheVisualStudiotoolchain.VisualStudioincludesabatchfile
tosettheseforyou,andinstallsashortcutintheStartmenutoopenacommandpromptwith
thesevariablesset.
2. Changelocationtothetopleveldirectoryofthesourcedistribution.
3. GeneratetheMakefilebyenteringthefollowingcommandinacommandpromptwindow:
shell> cmakeG"VisualStudio92008"

ForotherCMakeoptionsthatyoumightfinduseful,seeOtherConnector/CBuildOptions.
Theresultofthecmakecommandisaproject(solution)file,libmysql.sln,thatyoucanopen
withVisualStudio.Alternatively,buildfromthecommandlinewitheitherofthesecommands:
shell> devenv.comlibmysql.sln/buildRelease
shell> devenv.comlibmysql.sln/buildRelWithDebInfo

ForotherversionsofVisualStudioorforannmakebasedbuild,usethefollowingcommandto
checkwhichgeneratorscanbespecifiedwiththeGoption:
shell> cmakehelp

TocompileaDebugbuild,youmustsettheCMakebuildtypesothecorrectexternallibrary
versionsareused,thencompileusingtheDebugsolutionconfiguration:
shell> cmakeG"VisualStudio92008"DCMAKE_BUILD_TYPE=Debug
shell> devenv.comlibmysql.sln/buildDebug

AnormalbuildbuildstheCAPIlibrariesforthelibdirectory.ADebugbuildadditionallybuilds
debuglibrariesforthelib/debugdirectory.Youmustusethedebuglibrariestocompileclients
builtusingthedebugCruntime.
http://dev.mysql.com/doc/connectorc/en/connectorcinstallationsource.html#connectorcbuildoptions

2/3

28/03/2015

MySQL::MySQLConnector/CDeveloperGuide::5.2InstallingConnector/CfromSource

4. UsetheinstalloperationprovidedbyyourdevelopmentenvironmenttoinstalltheConnector/C
headers,libraries,andutilities.YoucanalsousethisCMakecommand:
shell> cmakebuild.targetINSTALLconfigRelWithDebInfo

OtherConnector/CBuildOptions
ThefollowingtablesshowotheroptionsthatcanbeusedwhenbuildingConnector/Cfromsource.
Table5.1BuildOptionsforConnector/C6.1
BuildOption

Description

DWITH_SSL=system
DWITH_ZLIB=system

EnabledynamiclinkingtothesystemOpenSSLlibrary.
EnabledynamiclinkingtothesystemZliblibrary.

Table5.2BuildOptionsforConnector/C6.0
BuildOption

Description

DWITH_OPENSSL=1
DWITH_EXTERNAL_ZLIB=1

EnabledynamiclinkingtothesystemOpenSSLlibrary.
EnabledynamiclinkingtothesystemZliblibrary.

Previous/Next/Up/TableofContents

UserComments
PostedbyJeremyO'ConnoronJanuary120154:27am

[Delete][Edit]

IhavewrittenablogpostthatexplainshowtobuildtheMySQLConnector/CfromsourceonWindows
usingVisualStudioCommunity2013.ThebuildingofbothWin32andx64versionsarecovered.The
postisat:http://jeremyoconnor.co.za/blog/?p=7
Addyourowncomment

Top/Previous/Next/Up/TableofContents
2015,OracleCorporationand/oritsaffiliates

http://dev.mysql.com/doc/connectorc/en/connectorcinstallationsource.html#connectorcbuildoptions

3/3

You might also like