compile with no database

Topics: 3. Feature Requests, 5. Support
Feb 15 at 3:04 PM
Edited Feb 15 at 3:51 PM
Hi all,

at first, thanks for your work.
As a non programming guy, I need a little support to compile your software at linux w/o any data base support.

I will use your tool to create a json string, that I will send to my mqtt-server.

Different functions/ mqtt-clients in my network can than use this string, extract needed data and process further with this. (switch devices, send other messages, show at web pages etc)

(Yes, i know, I can compile the tool with sql* support an than switch to only use csv. But for the compiling it-self sql-related libraries needed. The device i will use for data collection have no databases installed and don't need any databases. I will not install any software which i don't use.)
(And further, I also don't need bluetooth ;) )

Can you please explain my, how can I compile w/o sql*? Thanks!

Best regards from Berlin
Thomas
Coordinator
Feb 15 at 6:47 PM
Compiling without bluetooth isn't possible for now.
Without database, you can just
make release
Feb 16 at 8:16 AM
Edited Feb 16 at 8:17 AM
Thanks for the support,
Bloetooth are only a few kB - not a problem.
I have try to compile with:
  make release
but i have run in to error:
[root@infrastructure SBFspot]# make release
test -d bin/Release || mkdir -p bin/Release
test -d obj/Release || mkdir -p obj/Release
g++ -Wall -O2  -c Bluetooth.cpp -o obj/Release/Bluetooth.o
g++ -Wall -O2  -c CSVexport.cpp -o obj/Release/CSVexport.o
g++ -Wall -O2  -c Ethernet.cpp -o obj/Release/Ethernet.o
g++ -Wall -O2  -c EventData.cpp -o obj/Release/EventData.o
g++ -Wall -O2  -c ArchData.cpp -o obj/Release/ArchData.o
g++ -Wall -O2  -c SBFspot.cpp -o obj/Release/SBFspot.o
SBFspot.cpp: In function ‘E_SBFSPOT initialiseSMAConnection(InverterData*)’:
SBFspot.cpp:1408:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if (DEBUG_NORMAL)
     ^~
SBFspot.cpp:1413:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
  do
  ^~
SBFspot.cpp: In function ‘int GetConfig(Config*)’:
SBFspot.cpp:2457:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if (strlen(cfg->plantname) == 0)
     ^~
SBFspot.cpp:2460:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
  if (cfg->timezone.empty())
  ^~
SBFspot.cpp: In function ‘E_SBFSPOT setDeviceData(InverterData*, LriDef, uint16_t, Rec40S32&)’:
SBFspot.cpp:3252:5: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
     else
     ^~~~
SBFspot.cpp:3255:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘else’
  return rc;
  ^~~~~~
SBFspot.cpp: In function ‘E_SBFSPOT getDeviceData(InverterData*, LriDef, uint16_t, Rec40S32&)’:
SBFspot.cpp:3280:5: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
     else
     ^~~~
SBFspot.cpp:3283:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘else’
  int validPcktID = 0;
  ^~~
g++ -Wall -O2  -c TagDefs.cpp -o obj/Release/TagDefs.o
g++  -o bin/Release/SBFspot obj/Release/boost_ext.o obj/Release/misc.o obj/Release/strptime.o obj/Release/sunrise_sunset.o obj/Release/SBFNet.o obj/Release/Bluetooth.o obj/Release/CSVexport.o obj/Release/Ethernet.o obj/Release/EventData.o obj/Release/ArchData.o obj/Release/SBFspot.o obj/Release/TagDefs.o   -s -lboost_date_time -lboost_system -lpthread
obj/Release/Bluetooth.o: In function `bthConnect(char*)':
Bluetooth.cpp:(.text+0x31): undefined reference to `str2ba'
collect2: error: ld returned 1 exit status
makefile:89: recipe for target 'out_release' failed
make: *** [out_release] Error 1 
From my point of view, only the last few lines are the problem - all after Bluetooth.
But I can not find the solution.
I have look for the recipe for "release_out", the recipe exists in make-file.

Best regards
Thomas
Coordinator
Feb 16 at 11:13 AM
Did you install libbluetooth-dev?
The "misleading-indentation" warnings can be ignored (see issue 160)
Feb 16 at 1:25 PM
As i running a fedora system i have install bluetooth as
[root@infrastructure SBFspot]# dnf history
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    55 | install bluez-libs-devel | 2017-02-15 17:55 | Install        |    2   
    54 | install gcc-c++          | 2017-02-15 17:41 | Install        |    2   
    53 | install boost-devel.i686 | 2017-02-15 17:22 | Install        |   25   
Thanks for your response

Thomas
Coordinator
Feb 16 at 7:52 PM
It looks like the linker doesn't find libbluetooth
sudo find / -name libbluetooth.so
returns (on my Fedora 24)
/usr/lib64/libbluetooth.so
Let gcc print its search paths
gcc -print-search-dirs
returns a bunch of directories (Look at the libraries part)
...
/usr/lib/../lib64/ (This is the one we need)
...
If it's not in the list, add it with
export LD_LIBRARY_PATH=/usr/lib64
Feb 17 at 9:20 AM
Thank's for your responds!

I have used your approach but that's not the solution in my case :
[root@infrastructure SBFspot]# find / -name libbluetooth.so
/usr/lib/libbluetooth.so
[root@infrastructure SBFspot]# gcc -print-search-dirs
install: /usr/lib/gcc/i686-redhat-linux/6.3.1/
programs: =/usr/libexec/gcc/i686-redhat-linux/6.3.1/:/usr/libexec/gcc/i686-redhat-linux/6.3.1/:/usr/libexec/gcc/i686-redhat-linux/:/usr/lib/gcc/i686-redhat-linux/6.3.1/:/usr/lib/gcc/i686-redhat-linux/:/usr/lib/gcc/i686-redhat-linux/6.3.1/../../../../i686-redhat-linux/bin/i686-redhat-linux/6.3.1/:/usr/lib/gcc/i686-redhat-linux/6.3.1/../../../../i686-redhat-linux/bin/
libraries: =/usr/lib/gcc/i686-redhat-linux/6.3.1/:/usr/lib/gcc/i686-redhat-linux/6.3.1/../../../../i686-redhat-linux/lib/i686-redhat-linux/6.3.1/:/usr/lib/gcc/i686-redhat-linux/6.3.1/../../../../i686-redhat-linux/lib/:/usr/lib/gcc/i686-redhat-linux/6.3.1/../../../i686-redhat-linux/6.3.1/:/usr/lib/gcc/i686-redhat-linux/6.3.1/../../../:/lib/i686-redhat-linux/6.3.1/:/lib/:/usr/lib/i686-redhat-linux/6.3.1/:/usr/lib/
[root@infrastructure SBFspot]# make release
test -d bin/Release || mkdir -p bin/Release
test -d obj/Release || mkdir -p obj/Release
g++  -o bin/Release/SBFspot obj/Release/boost_ext.o obj/Release/misc.o obj/Release/strptime.o obj/Release/sunrise_sunset.o obj/Release/SBFNet.o obj/Release/Bluetooth.o obj/Release/CSVexport.o obj/Release/Ethernet.o obj/Release/EventData.o obj/Release/ArchData.o obj/Release/SBFspot.o obj/Release/TagDefs.o   -s -lboost_date_time -lboost_system -lpthread
obj/Release/Bluetooth.o: In function `bthConnect(char*)':
Bluetooth.cpp:(.text+0x31): undefined reference to `str2ba'
collect2: error: ld returned 1 exit status
makefile:89: recipe for target 'out_release' failed
make: *** [out_release] Error 1
You see, I have the right file at the system and it's also in the search path.
Must I configure a bluetooth device to fulfil the request "Bluetooth.cpp:(.text+0x31): undefined reference to `str2ba'" ?

Best regards

Thomas
Coordinator
Feb 20 at 7:32 PM
Add this piece of code to Bluetooth.cpp (starting at line 297)
void baswap(bdaddr_t *dst, const bdaddr_t *src)
{
    register unsigned char *d = (unsigned char *) dst;
        register const unsigned char *s = (const unsigned char *) src;
    register int i;

        for (i = 0; i < 6; i++)
              d[i] = s[5-i];
}

int str2ba(const char *str, bdaddr_t *ba)
{
       uint8_t b[6];
       const char *ptr = str;
       int i;

       for (i = 0; i < 6; i++) {
             b[i] = (uint8_t) strtol(ptr, NULL, 16);
             if (i != 5 && !(ptr = strchr(ptr, ':')))
                     ptr = ":00:00:00:00:00";
             ptr++;
       }
 
       baswap(ba, (bdaddr_t *) b);

       return 0;
}
Source
Marked as answer by thetamy on 2/28/2017 at 12:16 AM
Feb 28 at 7:18 AM
HI,
sorry for this late answer, but I was on a business trip for a couple of dais.
Thanks for your support!
regards
Thomas