Blynk Library C++ Linux, make shared object library problem

Hello everybody
I’ve tried Blynk Library’s C++ approach, made by @Costas
[Using C++ on a Raspberry Pi with Blynk]
I’m only interested in Virtual Pins, so, i compiled against “target=linux” .
It works fine in my Linux PC (Ubuntu 16.04 32bit) as well as in my tiny i.MX233 linux board (archlinux, kernel 2.6.35).
Then i had the idea to export common Blynk functions to a shared object library (name it libblynk.so)
I started with main.cpp example which modified as follows

/**
 * @file       main.cpp
 * @author     Volodymyr Shymanskyy
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
 * @date       Mar 2015
 * @brief
 */

#define BLYNK_PRINT stdout
#include <BlynkApiLinux.h>
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);

#include <BlynkWidgets.h>

void virtualWrite(int handle,double value){
Blynk.virtualWrite(handle,value);
}

void virtualWrite(int handle,char * value){
Blynk.virtualWrite(handle,value);
}

void setProperty(int handle, char * property, char * value){
Blynk.setProperty(handle,property,value);
}

void begin(const char *auth,const char *serv,uint16_t port){
Blynk.begin(auth, serv, port);
}
void run(){
Blynk.run();
}

int main(int argc, char* argv[])
{
    const char *auth, *serv;
    uint16_t port;
auth="e72fd035f50b44d08e43b92356b00975";
serv="blynk-cloud.com";
port=8442;
    //parse_options(argc, argv, auth, serv, port);
//printf(serv);    
	begin(auth, serv, port);   
    while(true) {
      	run();
    }
    return 0;
}

At this point, i’m interested to expose in the library only some basic functions for testing, as per main.h below

/*--- main.h---*/
typedef unsigned int uint16_t;
extern void virtualWrite(int,double);
extern void virtualWrite(int,char *);
extern void setProperty(int, char *, char *);
extern void begin(const char *,const char *,uint16_t);
extern void run();

In order to compile and link, i made the following script

#!/bin/bash
g++ -I ../src/ -I ./ -fPIC -DLINUX -c -O3 -w main.cpp -o main.o
g++ -I ../src/ -I ./ -fPIC -DLINUX -c -O3 -w BlynkDebug.cpp -o BlynkDebug.o
g++ -I ../src/ -I ./ -fPIC -DLINUX -c -O3 -w ../src/utility/BlynkHandlers.cpp -o ../src/utility/BlynkHandlers.o
g++ -I ../src/ -I ./ -fPIC -DLINUX -c -O3 -w ../src/utility/BlynkTimer.cpp -o ../src/utility/BlynkTimer.o
g++ -shared -o libblynk.so main.o BlynkDebug.o ../src/utility/BlynkHandlers.o ../src/utility/BlynkTimer.o

It ends up with the libblynk.so file created, so, i guess everything is fine!
Now, it’s time to link it with an executable just to test it
For this, i prepare test.cpp as follows

#include <main.h>
            int main(int argc, char* argv[])
            {
                const char *auth, *serv;
                uint16_t port;    
            auth="e72fd035f50b44d08e43b92356b00975";
            serv="blynk-cloud.com";
            port=8442;
            	begin(auth, serv, port);    
                while(true) {       
            	run();   
             }
                return 0;
            }

Finally i compile as follows

g++ -I. -L. -o testso test.cpp -lblynk

And i get the following response

/tmp/ccmidSjd.o: In function `main':
test.cpp:(.text+0x33): undefined reference to  `begin(char const*, char const*, unsigned int)'
collect2: error: ld returned 1 exit status

Any idea on what’s going on?

Best Regards
Kostas

What was you reason for changing:

Blynk.begin(auth, serv, port);

to:

Hi,
i’m not familiar at all with C++, i’m just trying to use gcc/g++ in a reliable way.
With the wrapper functions i want to hide the details of Blynk object creation and limited into it’s use.
My final target (hopefully), is to use “libblynk.so” to access Blynk library from Java, through “Java Native Interface”

B.R
Kostas