Can not get g++ to compile on Pi


3 posts
by tuxtux » Thu Aug 29, 2013 11:14 am
Hi Guys,

After looking around, googling and searching for something suitable for Modbus, I have found
some software but can not get it to compile.

My knowledge is close to 0 on writing code (C++) but I have tried compiling some source on "big" machines before. I have done some Perl programming.

Here is the issue at hand:

The code I am trying to compile is at:
http://www.modbusdriver.com/modpoll.html

When invoking g++ in any number of ways and with any number of switches, I can not get it to work.

There are 4 files required as "FieldTalk package headers"
MbusAsciiMasterProtocol.hpp
MbusRtuMasterProtocol.hpp
MbusRtuOverTcpMasterProtocol.hpp
MbusTcpMasterProtocol.hpp

I have put them together in the /usr/include directory as they did not work
in the directory where I compiled them, despite trying to tell the compiler where to find them.

This is one of my typical results.

g++ Wall -c modpoll.cpp
In file included from modpoll.cpp:40:0:
MbusRtuMasterProtocol.hpp:35:40: fatal error: MbusSerialMasterProtocol.hpp: No such file or directory
compilation terminated.

I know it is little info but I'm lost. If I can not even get this to go, there is little hope
of me ever getting a Modbus master going to read my measurement meter.

I have installed libmodbus and libmodbus-dev to see if I could write some
code using those libraries but have no sample code at all:-(

So, I'm not expecting someone to do it all for me, just point me the right way
so I can get something going.

There are no Make files for the code.

Edit: Forgot to mention, I am running standard Wheezy with all updates applied, all working good.
Posts: 2
Joined: Thu Aug 29, 2013 10:35 am
by SteveSpencer » Thu Aug 29, 2013 1:19 pm
A couple of things;

how were you telling the compiler where to find the hpp files? Presumably a g++ option, but which one?

Secondly, the hpp files refer to other hpp files you haven't copied. This is obvious from the error message:

MbusRtuMasterProtocol.hpp:35:40: fatal error: MbusSerialMasterProtocol.hpp: No such file or directory


The first part is the file that caused the problem, along with a line and column number (35 and 40 respectively). The second part ('fatal error:' and onward is telling what the problem is.

You need to check the hpp files and see what other headers they need.

Steve
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...
Posts: 123
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK
by tuxtux » Sun Sep 01, 2013 11:42 am
I will have a closer look, think the serial bus .hpp file is missing.

Will go through it and make sure all .hpp files are present.

Thanks, will give an update when all tested.
Posts: 2
Joined: Thu Aug 29, 2013 10:35 am