Compiling the 2.0.x opendnp3 DemoMain.cpp

334 views
Skip to first unread message

obinna Igbe

unread,
Jun 11, 2015, 3:13:34 PM6/11/15
to automat...@googlegroups.com
Hi all,

I am new to this branch of the opendnp3 library and also new to C++. I have successfully compiled the opendnp3  library on my Ubuntu 14.02 machine.  The libraries were installed in my /usr/lib directory, same with the executable masterdemo and outstationdemo. Now tried running the demo's and all worked fine. But I tried modifying the IP address of the outstation in the DemoMain.cpp in other to put the two (master and outstation) on two different systems, but couldn't seem to pass this stage.

I used the following line for compiling the demomain.cpp:

g++ -L /usr/lib -Wl,-rpath=/usr/lib -o executable_filename DemoMain.cpp -lopendnp3 -lasiodnp3

but I keep getting :

fatal error: asiodnp3/DNP3Manager.h: No such file or directory
 #include <asiodnp3/DNP3Manager.h>

compilation terminated.

What is it that am missing or doing wrongly? Also, do I need to add this file "masterdemo-DemoMain.o " to this compilation line (though I added it, and still got same error)?

Thanks in anticipation of your response.

Obinna 

Untitled.jpg

J Adam Crain

unread,
Jun 11, 2015, 11:32:37 PM6/11/15
to automat...@googlegroups.com, obii...@gmail.com
In this case, the compiler is complaining that it can't find the referenced header file.

This is an "include" problem, not a linking problem. You need to use the -I flag in GCC to tell the compiler where the various headers are.

Compile the demo applications using the supplied autotools scripts, and take note of all the compiler flags that are used when building the demos.

-Adam

obinna Igbe

unread,
Jun 13, 2015, 3:07:21 PM6/13/15
to automat...@googlegroups.com, obii...@gmail.com
Hi Adam,
I moved the include opendnp3 library files to a folder I called "opendnp3", and used the command below,

g++ --std=c++11 -o DemoMain DemoMain.cpp -lopendnp3 -lasiodnp3 -I/home/obinna/opendnp3 -I/home/obinna/asio/asio/include

but my compiler still requests for a header file "/boost/config.hpp"

See my attached screen cut. Just to re-iterate, I made changes to the demomain.cpp(changed IP address from 127.0.0.1 to 192.x.x.x) and my intention is to compile this demomain.cpp file. Thanks.
Capture.PNG

J Adam Crain

unread,
Jun 13, 2015, 5:53:49 PM6/13/15
to automat...@googlegroups.com, obii...@gmail.com
You're getting closer. You also need to define the following:


-DASIO_STANDALONE tells the ASIO to compile in C++11 only mode without a need for BOOST.

As I mentioned previously, just examine the compiler command line arguments that are used when building the demos using the supplied toolchain. This will tell you all the things you need to set when using opendnp3 in your own application.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages