Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot find valid reference
    primarykey
    data
    text
    <p>I have a c file for hardware initialization and a c++ file that calls methods from it. When I attempt to compile them using g++, I get the following</p> <pre><code>g++ testPegio.cpp -o testPeg </code></pre> <p>I get the following:</p> <blockquote> <p>In file included from /usr/include/c++/4.6/chrono:35:0, from testPegio.cpp:6: /usr/include/c++/4.6/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.</p> </blockquote> <p>So I try this:</p> <pre><code>g++ testPegio.cpp -o testPeg -std=c++0x </code></pre> <p>And I get:</p> <blockquote> <p>/tmp/cczOOOyb.o: In function <code>main': testPegio.cpp:(.text+0xc): undefined reference to</code>pegio_init' collect2: ld returned 1 exit status</p> </blockquote> <p>Here are the important snippets of code:</p> <p>pegio.h</p> <pre><code>#include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;unistd.h&gt; //used for uart #include &lt;fcntl.h&gt; //used for uart #include &lt;termios.h&gt; //used for uart #include &lt;string.h&gt; #include &lt;string&gt; #define BAUD_RATE B1152000 #define BYTE_SIZE CS8 #define MAX_STRING_LEN 80 #define true 1 #define false 0 typedef int bool; extern char pegio_init(void); // initialize serial port extern char pegio_deinit(void); // deinitialize serial port extern void pegio_serial_write(char inStr[MAX_STRING_LEN]); // serial write method extern void pegio_serial_read(char * str); // serial read method extern bool charCheck(char ch); // character check </code></pre> <p>pegio.c</p> <pre><code>#include "pegio.h" int uart0_filestream = -1; // ** INITIALIZE THE UART ** char pegio_init(void) { uart0_filestream = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY | O_NDELAY); if (uart0_filestream == -1) { //ERROR - Can't open serial port printf("Error - Unable to open UART. Ensure it is not in use by another application\n"); } struct termios options; tcgetattr(uart0_filestream, &amp;options); options.c_cflag = BAUD_RATE | BYTE_SIZE | CLOCAL | CREAD; //&lt;Set the baud rate options.c_iflag = IGNPAR | ICRNL; options.c_oflag = 0; options.c_lflag = 0; tcflush(uart0_filestream, TCIFLUSH); tcsetattr(uart0_filestream, TCSANOW, &amp;options); return 0; } // ** DEINITIALIZE THE UART ** char pegio_deinit() { close(uart0_filestream); return 0; } </code></pre> <p>And finally, testPeg.cpp</p> <pre><code>extern "C" { #include "pegio.h" } #include &lt;iostream&gt; #include &lt;chrono&gt; #include &lt;stdlib.h&gt; int main() { int result = pegio_init(); return result; } </code></pre> <p>Any ideas??</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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