Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sure ... C code is called from C++ all the time. For instance, most OS libraries are written in C rather than C++. So whenever you're making syscalls from your C++ code to perform tasks that are handed over to the OS kernel, those are going through C-code calls.</p> <p>Just be sure to include the proper headers and link against the C-libraries in question at compile time. Also remember to use <a href="https://stackoverflow.com/questions/1041866/in-c-source-what-is-the-effect-of-extern-c"><code>extern "C"</code></a> to specify C-linkage for the C-library functions if the header files have not already declared them as such. Keep in mind that some libraries may not have declared their functions specifically using <code>extern "C"</code>, but may have used a pre-processor token to-do so. So you'll want to check for that as well before you assume the library writers did not already define their library as having C-linkage.</p> <p>linking custom libraries using <code>gcc</code> can be done with the <code>-l</code> switch. If you need to specify a custom directory for where the libraries are located, that can be done with the <code>-L</code> switch. So for instance:</p> <pre><code>g++ -std=c++11 my_code.cpp -lmy_library -L/custom_directory_path </code></pre> <p>Note that the <code>-l</code> and <code>-L</code> switches come <em>after</em> the code or object files you're compiling, and if you're library is something like <code>libjpg</code>, or <code>librobotics</code>, etc., drop the <code>lib</code> part of the name when you append it to the <code>-l</code> switch.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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