Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ multi-stage linking
    text
    copied!<p>Ok, so this might not be a great question, but I'm a bit stuck.</p> <p>I have 3 programs:</p> <blockquote> <p>pegio.c/pegio.h - Does hardware initialization and functions for my device</p> <p>PegIOHandler.cpp/PegIOHandler.h - Handles I/O for device</p> <p>PegRTU.cpp - Main function</p> </blockquote> <p>My project implements the opendnp3 (which allows one to transmit data using the DNP3 protocol) library. Now, to compile it I first compile the pegio.c file</p> <pre><code>gcc -c pegio.c -o pegio.o </code></pre> <p>Easy, up to here I understand.</p> <p>Secondly I compile the IOHandler and reference pegio.c as it uses it.</p> <pre><code>g++ -c PegIOHandler.cpp pegio.c -o PegIOHandler.o -std=c++0x </code></pre> <p>Now it gives me the following output.</p> <blockquote> <p>g++: warning: pegio.o: linker input file unused because linking not done</p> </blockquote> <p>But, it still creates the object file. HOWEVER, PegIOHandler implements opendnp3 header files, which is included in PegIOHandler.cpp and PegIOHandler.h. When I attempt to compile these files without using the '-c', it tells me that there are undefined references to the opendnp3 files. I know I have to link them to my project, but how do I do that?</p> <p>Then compililing my third and final file:</p> <pre><code>g++ PegRTU.cpp pegio.o PegIOHandler.o -o pegrtu -std=c++0x </code></pre> <p>This now tells me that there are undefined references to the opendnp3 files. So: How do I link the opendnp3 library to my project / code files??? Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload