Error when compiling code

Hello,

I'm trying to connect to one MS SQL Server, for that I'm using the following library: https://github.com/mustafakemalgilor/arduino-mssql

I'm using the sample code just to test me connections the sample code is the following:

 #include <Ethernet.h>
#include "sqlard.h"


uint8_t Ethernet_MacAddr[6] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; /* MAC ADRESİ */
static byte Static_IPAddr[] = { 172,16,1,2 };            
static byte Gateway_IPAddr[] = { 172,16,1,1 };
static byte Subnet_Mask[] = { 255,255,0,0 };
EthernetClient client;

SQLard MSSQL(Gateway_IPAddr, 1433, &client);
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial); 
  Ethernet.begin(Ethernet_MacAddr, Static_IPAddr, Gateway_IPAddr, Gateway_IPAddr, Subnet_Mask);
  if(MSSQL.connect())
  {
      MSSQL.setCredentials(L"arduino", L"ard_login",L"ard_password",L"hostx");
      MSSQL.login();
  }
  
}

void loop() {
  // put your main code here, to run repeatedly:
  int loop_count = 0;
  delay(5000);

  long affected_rows = MSSQL.executeNonQuery(L"INSERT INTO [dbo].[test]([data]) VALUES('deger1234') ");
  long yeni = MSSQL.executeNonQuery(L"DROP TABLE [dbo].[test23]");
  Serial.print(affected_rows);
  Serial.println(" row(s) affected.");
  if (!client) {
    Serial.println("disconnecting.");
    client.stop();
  }
  if(++loop_count == 10)
  {
    MSSQL.executeNonQuery(L"DELETE FROM [dbo].[test]");
    loop_count = 0;
  }
}

I'm getting this error: arduino-mssql-master/sqlard.h:13:12: fatal error: UIPEthernet.h: No such file or directory Utilizado: C:\Arduino\libraries\Ethernet

After installing UIPEthernet library I get the following errors when compiling:

In file included from C:\Documents\Arduino\libraries\UIPEthernet/utility/mempool_conf.h:5:0,
                 from C:\Documents\Arduino\libraries\UIPEthernet/utility/mempool.h:28,
                 from C:\Documents\Arduino\libraries\UIPEthernet/utility/Enc28J60Network.h:28,
                 from C:\Documents\Arduino\libraries\UIPEthernet/UIPEthernet.h:35,
                 from C:\Documents\Arduino\libraries\arduino-mssql-master/sqlard.h:13,
                 from C:\sqlard_test\sqlard_test.ino:2:
C:\Documents\Arduino\libraries\UIPEthernet/utility/uipopt.h:97:4: warning: #warning "Endianness configured automaticaly." [-Wcpp]
   #warning "Endianness configured automaticaly."
    ^~~~~~~
In file included from C:\Documents\Arduino\libraries\UIPEthernet/UIPClient.h:37:0,
                 from C:\Documents\Arduino\libraries\UIPEthernet/UIPEthernet.h:41,
                 from C:\Documents\Arduino\libraries\arduino-mssql-master/sqlard.h:13,
                 from C:\sqlard_test\sqlard_test.ino:2:
C:\Documents\Arduino\libraries\UIPEthernet/utility/logging.h:24:2: warning: #warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage." [-Wcpp]
 #warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
  ^~~~~~~
In file included from C:\Documents\Arduino\libraries\UIPEthernet/UIPEthernet.h:37:0,
                 from C:\Documents\Arduino\libraries\arduino-mssql-master/sqlard.h:13,
                 from C:\sqlard_test\sqlard_test.ino:2:
C:\Documents\Arduino\libraries\UIPEthernet/Dhcp.h:153:7: error: redefinition of 'class DhcpClass'
 class DhcpClass {
       ^~~~~~~~~
In file included from C:\sqlard_test\sqlard_test.ino:1:0:
C:\Documents\Arduino\libraries\Ethernet\src/Ethernet.h:273:7: note: previous definition of 'class DhcpClass'
 class DhcpClass {
       ^~~~~~~~~
In file included from C:\Documents\Arduino\libraries\arduino-mssql-master/sqlard.h:13:0,
                 from C:\sqlard_test\sqlard_test.ino:2:
C:\Documents\Arduino\libraries\UIPEthernet/UIPEthernet.h:69:6: error: multiple definition of 'enum EthernetLinkStatus'
 enum EthernetLinkStatus {
      ^~~~~~~~~~~~~~~~~~
In file included from C:\sqlard_test\sqlard_test.ino:1:0:
C:\Documents\Arduino\libraries\Ethernet\src/Ethernet.h:56:6: note: previous definition here
 enum EthernetLinkStatus {
      ^~~~~~~~~~~~~~~~~~
In file included from C:\Documents\Arduino\libraries\arduino-mssql-master/sqlard.h:13:0,
                 from C:\sqlard_test\sqlard_test.ino:2:
C:\Documents\Arduino\libraries\UIPEthernet/UIPEthernet.h:75:6: error: multiple definition of 'enum EthernetHardwareStatus'
 enum EthernetHardwareStatus {
      ^~~~~~~~~~~~~~~~~~~~~~
In file included from C:\sqlard_test\sqlard_test.ino:1:0:
C:\Documents\Arduino\libraries\Ethernet\src/Ethernet.h:62:6: note: previous definition here
 enum EthernetHardwareStatus {
      ^~~~~~~~~~~~~~~~~~~~~~
Foram encontradas múltiplas bibliotecas para «Ethernet.h»
Utilizado: C:\Documents\Arduino\libraries\Ethernet
Não utilizado: C:\Documents\Arduino\libraries\UIPEthernet
exit status 1
Error compiling to Arduino Uno.

Can someone help me figure out why I'm getting all these errors now?

Thanks

Hello @SuperM

So, the latest errors are from two libraries having the same function names; hence the error: multiple definition of ....

I checked out the library; as the author states multiple times, it is very outdated and rudimentary in function. It looks like there is a way to fix it though to get it to compile.

Try changing this part in the sqlard.h file:

#ifndef SQLARD_H
#define SQLARD_H
#define UIPETHERNET
#include <stdarg.h>

#ifdef WINDOWS
	#define F 
	#define PROGMEM
	#include <boost/array.hpp>
	#include <boost/asio.hpp>
#else
	#ifdef UIPETHERNET
		#include <UIPEthernet.h>
	#else 
		#include <Ethernet.h>
	#endif
#endif

to this:

#ifndef SQLARD_H
#define SQLARD_H
#include <stdarg.h>

#include <Ethernet.h>

Also, delete the UIPEthernet.h library you just downloaded, then try uploading the code again.

I hope that fixes it!

I did the changes and now the error is the following:

C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp: In function 'int main()':
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp:14:28: error: no matching function for call to 'SQLard::SQLard(unsigned char [4], short unsigned int&)'
   SQLard MSSQL(ipAddr, port);
                            ^
In file included from C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp:3:0:
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard.h:1077:3: note: candidate: SQLard::SQLard()
   SQLard() {
   ^~~~~~
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard.h:1077:3: note:   candidate expects 0 arguments, 2 provided
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard.h:1070:3: note: candidate: SQLard::SQLard(uint8_t*, uint16_t, EthernetClient*)
   SQLard(uint8_t * serverIP, const uint16_t port, EthernetClient * pEthCl) {
   ^~~~~~
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard.h:1070:3: note:   candidate expects 3 arguments, 2 provided
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard.h:1045:7: note: candidate: constexpr SQLard::SQLard(const SQLard&)
 class SQLard
       ^~~~~~
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard.h:1045:7: note:   candidate expects 1 argument, 2 provided
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard.h:1045:7: note: candidate: constexpr SQLard::SQLard(SQLard&&)
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard.h:1045:7: note:   candidate expects 1 argument, 2 provided
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp:28:6: error: 'wprintf' was not declared in this scope
      wprintf(L"%s|", tr->m_arColumnData[i]->m_wcstrColumnName);
      ^~~~~~~
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp:28:6: note: suggested alternative: 'vprintf'
      wprintf(L"%s|", tr->m_arColumnData[i]->m_wcstrColumnName);
      ^~~~~~~
      vprintf
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp:82:9: error: 'time_t' was not declared in this scope
         time_t val = pField->asDateTime();
         ^~~~~~
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp:82:9: note: suggested alternative: 'size_t'
         time_t val = pField->asDateTime();
         ^~~~~~
         size_t
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp:83:19: error: aggregate 'main()::tm q' has incomplete type and cannot be defined
         struct tm q;
                   ^
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp:84:26: error: 'val' was not declared in this scope
         localtime_s(&q, &val);
                          ^~~
C:\Documents\Arduino\libraries\arduino-mssql-master\sqlard-test.cpp:84:9: error: 'localtime_s' was not declared in this scope
         localtime_s(&q, &val);
         ^~~~~~~~~~~
exit status 1
Erro ao compilar para a placa Arduino Uno.

Could you please post your edited sqlard.h file?

Hello, I'm the author of the arduino-mssql library. I'm a little bit late to the party, and I have both bad and good news for you. The bad news is, the arduino-mssql library is abandoned and will not be maintained. It was a toy anyways, not meant to be used in any kind of project.

The good news is; I've developed a successor for arduino-mssql named tdslite. It's written in pure C++11 with portability, flexibility and it supports running queries, retrieving result sets, and executing queries with bound input parameters right now. It supports a wide range of embedded devices, SoC's and IoT devices. It should work for any platform that has a decent, C++11-compatible compiler.

It's available on Arduino Library Manager with tdslite name. You can also manually download and install the .zip file from GitHub Releases page of the project.

Check it out!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.