Modbus compile error

Hi All,

I have a problem to compile the Modbus class. I created the Makefile with POGO. I have this error:"./obj/ClassFactory.o: In function `Tango::DServer::class_factory()':
undefined reference to `Serial_ns::SerialClass::init(char const*)'
collect2: error: ld returned 1 exit status
/usr/local/share/pogo/preferences/common_target.opt:102: recipe for
target '/home/tango-cs/DeviceServers/Modbus' failed
make: *** [/home/tango-cs/DeviceServers/Modbus] Error 1
I think I have included all the necessary files(for example SerialClass.h).

I'm usingUbuntu 18( TangoBox-9.3).

I have the same issue Salvo. I have improvised a workaround in case you are not going to use the serial method class (just Modbus). The shortcut is to comment the serial method class, pretty drastic but it compiles and works. I don't know if there is major implications in doing that. Hope it helps, if you have solved root problem please contact me.

/*—– PROTECTED REGION ID(Modbus::ClassFactory.cpp) ENABLED START —–*/
static const char *RcsId = "$Id: $";
// file : ClassFactory.cpp
// description : C++ source for the class_factory method of the DServer
// device class. This method is responsible for the creation of
// all class singleton for a device server. It is called
// at device server startup.
// project : Modbus
// This file is part of Tango device class.
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Tango. If not, see <>.
// $Author: $
// $Revision: $
// $Date: $
// $HeadURL: $
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)

#include <tango.h>
#ifndef NOSERIAL
#include <SerialClass.h>
#include <ModbusClass.h>

// Add class header files if needed
* Create Modbus Class singleton and store it in DServer object.

void Tango::DServer::class_factory()
// Add method class init if needed
// #ifndef NOSERIAL
// add_class(Serial_ns::SerialClass::init("Serial"));
// #endif
/*—– PROTECTED REGION END —–*/ // Modbus::ClassFactory.cpp
I found a better solution.

I have generated a new makefile with POGO as suggested in this post ( but the resulting makefile is different from the original. So Serial.h, Serial.cpp, SerialClass.h and SerialClass.cpp from SerialLine class must be copied into working directory to compile. Is then when the "undefined reference to" error rises, if we compare both makefiles…


# MAKE_ENV is the path to find common environment to buil project
MAKE_ENV = /segfs/tango/cppserver/env

SERIAL_DIR = /segfs/tango/cppserver/protocols/SerialLine/src

POGO SELF GENERATED (if java-tools is installed from package)

# MAKE_ENV is the path to find common environment to buil project
MAKE_ENV = /usr/share/pogo/preferences
As it can be noticed, SERIAL_DIR is missing in the self generated pogo makefile. The solution that works for me is to download SerialLine ( and use the original makefile replacing:

MAKE_ENV = /segfs/tango/cppserver/env
MAKE_ENV = /usr/share/pogo/preferences


SERIAL_DIR = /segfs/tango/cppserver/protocols/SerialLine/src
SERIAL_DIR = /yourpathtoclonedSerialLineclass/trunk/src

With SerialLine source directory located you make sure all the SerialLine necessary files used in Modbus are well referenced. Is important then take into account that the original MAKE_ENV and SERIAL_DIR are a particular case of location files for the developer and you may change it to your convenience.

Hope it helps!smile
Edited 1 month ago
Register or login to create to post a reply.