mysql.cpp compilation error in MATLAB - c++

Hi Im trying to compile a c++ file viz. mysql.cpp for connecting Matlab to mysql database.
I used the same file before and was able to compile it without any issue but I had to re-install Matlab yesterday and when I tried compiling the file, I get many syntax errors although I have not made any changes in the cpp file.
For reference, the file was taken from here: -
http://www.mathworks.com/matlabcentral/fileexchange/8663-mysql-database-connector
I get the following errors:-
Error mysql.cpp: 57 illegal initialization for parameter 'n'
Error mysql.cpp: 98 syntax error; found 't' expecting ')'
Error mysql.cpp: 98 skipping 't'
Error mysql.cpp: 100 undeclared identifier 't'
Warning mysql.cpp: 100 possible usage of t before definition
Error mysql.cpp: 177 syntax error; found 'int' expecting ';'
Error mysql.cpp: 177 syntax error; found 'int' expecting ';'
Error mysql.cpp: 177 syntax error; found 'int' expecting ')'
Error mysql.cpp: 177 skipping 'int'
Error mysql.cpp: 177 undeclared identifier 'j'
Warning mysql.cpp: 177 Statement has no effect
Warning mysql.cpp: 177 unreachable code
Error mysql.cpp: 177 syntax error; found ')' expecting ';'
Error mysql.cpp: 177 illegal statement termination
Error mysql.cpp: 177 skipping ')'
Error mysql.cpp: 183 syntax error; found 'int' expecting ';'
Error mysql.cpp: 183 syntax error; found 'int' expecting ';'
Error mysql.cpp: 183 syntax error; found 'int' expecting ')'
Error mysql.cpp: 183 skipping 'int'
Error mysql.cpp: 183 undeclared identifier 'j'
Warning mysql.cpp: 183 Statement has no effect
Warning mysql.cpp: 183 unreachable code
Error mysql.cpp: 183 syntax error; found ')' expecting ';'
Error mysql.cpp: 183 illegal statement termination
Error mysql.cpp: 183 skipping ')'
Error mysql.cpp: 186 too many errors
I did the setup for mex using
mex -setup
and used the following command for compilation: -
mex -DWIN32 -I'D:\Softwares\MY SQL\mysql-5.6.12-win32\mysql-5.6.12-win32\include'
-L'D:\Softwares\MY SQL\mysql-5.6.12-win32\mysql-5.6.12-win32\lib' -llibmysql mysql.cpp
Any help is greatly appreciated!!

You could follow this by Chuck Saunders:
Here's how I got this to work on Matlab R2015a installed on a 64 bit Windows 7 install. I started with no compiler and no SQL installed:
Search for the "MySQL Community Installer", download it, then have it install the "full" option.
Check Add/Remove programs to see if you have Microsoft Visual C++ 2010 Redistributable packages installed, BOTH the (x86) and the (x64) packages will cause the Windows SDK 7.1 install to fail.
If you have them, search for the "Microsoft Fix It" utility. Run it, selecting "Uninstall", and use it to uninstall all of the VC++ 2010 redistributables.
Download and install Windows SDK. If the install fails and you didn't bother to run the Fix It utility, I told you so!
Once the Windows SDK is installed, you have to configure it. Go to Start->All Programs->Microsoft Windows SDK X.Y->Visual Studio Registration->Windows SDK Configuration Tool
If the config tool yells that you don't have Visual Studio 2005 or 2008 installed... go install it. I installed VS 2008.
Once all of this is done, on the Matlab prompt, type the line, "mex -setup", and verify that Windows SDK shows as an option and is selected (if you have other compilers - I only got this to work for me with the SDK so I can't comment re:anything else)
Now, making sure the 'mysql.m' and 'mysql.cpp' is in a folder on the Matlab path, run the compile command exactly as shown in the 'mysql.m' comments. For me, the path to my include and library files was: "C:\Program Files\MySQL\MySQL Server 5.6\" and then either "bin\" or "lib\" as appropriate for the command.
For your reference, that full command FOR ME was: mex -I"C:\Program Files\MySQL\MySQL Server 5.6\include" -DWIN32 mysql.cpp "C:\Program Files\MySQL\MySQL Server 5.6\lib\libmySQL.lib"
Again, this relies on using whatever version of MySQL that YOU have installed, so if you don't have MySQL 5.6 installed then you need to modify this command to point to the correct location.
At this point, the file should compile correctly, but you may get an error like several people below have gotten: "Invalid MEX-file :
The specified module could not be found" This error is because you have not copied the 'libmysql.dll' file from your \lib\ folder to whichever folder has the mysql.mex file. Once you do this, it should work!
Finally, for your reference, to be explicit, I have 'mysql.cpp', 'mysql.m', 'mysql.mexw64' all in my root Matlab folder, and then I copied 'libmysql.dll' from "C:\Program Files\MySQL\MySQL Server 5.6\lib\" to my root Matlab folder.

Related

Using Boost.Json lib in Visual Studio 2013

I have been trying to use new Boost.Json lib that was launched in the latest version of boost 1.75.0. For testing purposes I created an empty VS project and added one file and tried to build it. I added the directory in the project's additional include directory. This is what my source file looks like:
#include <boost\json.hpp>
void main(){
return;
}
When I compile this I get following error:
Error 8 error C1903: unable to recover from previous error(s); stopping compilation
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 5 error C2065: 'T' : undeclared identifier
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 7 error C2143: syntax error : missing ';' before
'boost::json::detail::static_const<T>::value'
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 2 error C2146: syntax error : missing ';' before identifier 'T'
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 308 1 Project1
Error 4 error C2146: syntax error : missing ';' before identifier 'T'
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 6 error C2923: 'boost::json::detail::static_const' : 'T' is not a valid template type
argument for parameter 'T' C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 1 error C3646: 'noexcept' : unknown override specifier
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 292 1 Project1
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 308 1 Project1
Just to verify if I included the boost lib right, I wrote another code
#include <boost\property_tree\json_parser.hpp>
void main(){
return;
}
and it compiled fine. The reason I want to use json lib instead of property trees is because I want to retain the data type of the json objects whereas trees parse everything in string. Any help will be really appreciated. Thank you.
Boost.JSON is not tested to compile with Visual Studio 2013. I doubt that it could ever work, as that version of the IDE and compiler does not support C++11 sufficiently for the library.

Libtorch operator/syntax errors in Visual Studio

Hi recently I’ve installed Libtorch and I was able to use it in my new Visual Studio project without a problem. Currently I am trying to use Libtorch in an existing CUDA project. But I am having these strange errors when I include torch header and I couldn’t find any solution in the internet regarding to my problem. Does anyone have any idea what might be the cause of these errors?
Severity Code Description Project File Line Suppression State
Error C2833 'operator {' is not a recognized operator or type DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2059 syntax error: 'newline' DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2238 unexpected token(s) preceding ';' DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2143 syntax error: missing ';' before 'const' DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2833 'operator {' is not a recognized operator or type DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Error C2059 syntax error: 'newline' DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Error C2238 unexpected token(s) preceding ';' DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Error C2143 syntax error: missing ';' before 'const' DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Environment
Windows 10
CUDA 10.1
Visual Studio 2017
C++14
Thanks to #john I have realized that there was a macro in another library which has the same name as a typename in Libtorch library(which was a macro called V in my case), that’s why it was confused in compilation. I am sticking to this solution for now.
warning C4003: not enough actual parameters for macro 'max' - Visual Studio 2010 C++

Using Cmake to build ssh.dll with Visual Studio 2017

I am a beginner in C++ and I am trying to build ssh.dll on Windows 32bit using Visual Studio 2017 and cmake. I have downloaded the latest version of libssh and tried to build ssh.dll from the source by using cmake after configuring and generating as per the recommended steps.
After generating, I opened the libssh solution file with Visual Studio 2017 and build it but while compiling it gave few missing library errors which I resolved by adding those libraries to the VC path.
After adding those libraries, it started giving me around 600 compilation errors like below related to syntax (but syntax looks correct in these library files) .
Is there a way or suggestion by which I can successfully resolve them and create .dll file ?
Below are some of those errors:
Severity Code Description Project File Line Suppression State
Error C2146 syntax error: missing ')' before identifier 'session' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\priv.h 196
Error C2061 syntax error: identifier 'channel' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\callbacks.h 64
Error C2059 syntax error: ';' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\callbacks.h 64
Error C2146 syntax error: missing ')' before identifier 'fd' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\libssh.h 656
Error C2059 syntax error: ')' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\libssh.h 597
Error C2081 'socket_t': name in formal parameter list illegal ssh_shared c:\apps\MVS15\VC\Tools\MSVC\14.10.25017\include\libssh\poll.h 135
Error C2059 syntax error: '}' ssh_shared c:\apps\MVS15\VC\Tools\MSVC\14.10.25017\include\libssh\session.h 203
Error C2146 syntax error: missing ')' before identifier 'fd' ssh_shared c:\apps\MVS15\VC\Tools\MSVC\14.10.25017\include\libssh\socket.h 36
Error C2059 syntax error: ';' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\callbacks.h 64
Error C2037 left of 'iqmp' specifies undefined struct/union 'rsa_st' ssh_shared C:\apps\vcpkg\downloads\libssh-0.7.6.tar\libssh-0.7.6\src\libcrypto-compat.c 77
Error C2037 left of 'dmq1' specifies undefined struct/union 'rsa_st' ssh_shared C:\apps\vcpkg\downloads\libssh-0.7.6.tar\libssh-0.7.6\src\libcrypto-compat.c 76
In order to resolve it, I also tried to replace the questionable library files with other version of these library files, but without any luck. What can I try next?
I just git a git clone and build it successfully.
Here is how I did it.
vcpkg install zlib:x64-windows openssl:x64-windows
# in vcpkg installed directory:
mkdir build
cd build
cmake .. -DCMAKE_GENERATOR_PLATFORM=x64 "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
For static linking include
-DVCPKG_TARGET_TRIPLET=x86-windows-static
Open the solution file in Visual Studio 2017 and it successfully builds.
2> Creating library ssh.lib
2>ssh_shared.vcxproj -> ....\build\src\Debug\ssh.dll
========== Build: 7 succeeded, 0 failed, 0 up-to-date, 4 skipped ==========
If you want to build for 32 bit architecture
vcpkg install zlib openssh
in the cloned source code
mkdir build
cd build
cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"

Visual Studio 2005 throws build error in soapclient.cpp I built with GSoap

I have built soapclient.cpp using GSoap libraries all built successfully, without any errors. Now included the necessary files to the project as instructed by the guide (http://www.genivia.com/dev.html#Example_gSOAP_client_(C++)), but getting following errors, included some here. has anyone come across it, any ideas?
i am using gSoap release 2.8.27
Includes:
soapH.h
soapStub.h
soapSubscribeNetBindingProxy.h
stdsoap2.h
SubscribeNetBinding.nsmap
soapC.cpp, soapClient.cpp, and stdsoap2.cpp
Errors---
Error 1 error C2079: 'soap_tmp_ns__echoString' uses undefined struct 'soap_call_ns__echoString::ns__echoString' c:\dev\riedel\riedellicencemanager\riedellicencemanager\subscribenetproxy\soapclient.cpp 23
Error 2 error C2228: left of '.inputString' must have class/struct/union c:\dev\riedel\riedellicencemanager\riedellicencemanager\subscribenetproxy\soapclient.cpp 27
Error 3 error C3861: 'soap_serialize_ns__echoString': identifier not found c:\dev\riedel\riedellicencemanager\riedellicencemanager\subscribenetproxy\soapclient.cpp 29
Error 4 error C3861: 'soap_put_ns__echoString': identifier not found c:\dev\riedel\riedellicencemanager\riedellicencemanager\subscribenetproxy\soapclient.cpp 36
Error 5 error C3861: 'soap_put_ns__echoString': identifier not found c:\dev\riedel\riedellicencemanager\riedellicencemanager\subscribenetproxy\soapclient.cpp 47
Error 6 error C3861: 'soap_get_ns__echoStringResponse': identifier not found c:\dev\riedel\riedellicencemanager\riedellicencemanager\subscribenetproxy\soapclient.cpp 60
Error 7 error C2027: use of undefined type 'soap_call_ns__echoString::ns__echoStringResponse' c:\dev\riedel\riedellicencemanager\riedellicencemanager\subscribenetproxy\soapclient.cpp 67
Error 8 error C2227: left of '->_return' must point to class/struct/union/generic type c:\dev\riedel\riedellicencemanager\riedellicencemanager\subscribenetproxy\soapclient.cpp 67 }
Do the following.
Remove any references to stdafx.h, from the project
Remove soapClient.cpp
Make sure each cpp file included is to 'Not using pre-compiled headers'
Include dom.h
Include dom.cpp
Project should compile now. if need further help start from calc_vs2005 project included in the gSoap.

Winbase.h doesn't support in creating DLL file

I would like to create a project use to call c++ method using c#. So, I need to create a dll file for all of my c++ function. But when i get an error in y sqlite source code such as "AreFileApisASNSI undeclared identifier". So, i import winbase.h which is part of the mingw-w64 runtime package to my visual studio 2012 express DLL project. After import the file, I get many errors such as below:-
error c4430: missing type specifier - int assumed. Note: C++ does not support default - int
error C2143: syntax error : missing ';' before '_stdcall'
error c1003 error count exceeds 100; stopping compilation
error c2061: syntax error: identifier ' WINBOOL'
error c2086: 'int_CRT_INLINE' : redefinition
error c2143: syntax error: missing ';' before ''
error C2146: syntax error : missing ';' before identifier 'LONGLONG'
error C2146: syntax error : missing ';' before identifier 'PVOID'
any solution for those error? please help!!
The documentation for the function has this header requirement:
WinBase.h (include Windows.h)
This is telling you that the function is declared in WinBase.h, but that you should include Windows.h which in turn will include WinBase.h. So, you need to change your include to
#include <Windows.h>
I also wonder why you are talking about mingw considering that your compiler is MSVC. That compiler ships with a comprehensive Windows SDK. Why would you be using an SDK from mingw?