| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 5 |
<meta http-equiv="X-UA-Compatible" content="IE=11"/> |
| 6 |
<meta name="generator" content="Doxygen 1.15.0"/> |
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 8 |
<title>Hardware Locality (hwloc): Compiling software on top of hwloc's C API</title> |
| 9 |
<link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 10 |
<script type="text/javascript" src="jquery.js"></script> |
| 11 |
<script type="text/javascript" src="dynsections.js"></script> |
| 12 |
<script type="text/javascript" src="clipboard.js"></script> |
| 13 |
<link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 14 |
</head> |
| 15 |
<body> |
| 16 |
<div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 17 |
<div id="titlearea"> |
| 18 |
<table cellspacing="0" cellpadding="0"> |
| 19 |
<tbody> |
| 20 |
<tr id="projectrow"> |
| 21 |
<td id="projectalign"> |
| 22 |
<div id="projectname">Hardware Locality (hwloc)<span id="projectnumber"> 2.14.0</span> |
| 23 |
</div> |
| 24 |
</td> |
| 25 |
</tr> |
| 26 |
</tbody> |
| 27 |
</table> |
| 28 |
</div> |
| 29 |
<!-- end header part --> |
| 30 |
<!-- Generated by Doxygen 1.15.0 --> |
| 31 |
<script type="text/javascript"> |
| 32 |
$(function() { codefold.init(); }); |
| 33 |
</script> |
| 34 |
<script type="text/javascript" src="menudata.js"></script> |
| 35 |
<script type="text/javascript" src="menu.js"></script> |
| 36 |
<script type="text/javascript"> |
| 37 |
$(function() { |
| 38 |
initMenu('',false,false,'search.php','Search',false); |
| 39 |
}); |
| 40 |
</script> |
| 41 |
<div id="main-nav"></div> |
| 42 |
</div><!-- top --> |
| 43 |
<div id="doc-content"> |
| 44 |
<div><div class="header"> |
| 45 |
<div class="headertitle"><div class="title">Compiling software on top of hwloc's C API </div></div> |
| 46 |
</div><!--header--> |
| 47 |
<div class="contents"> |
| 48 |
<div class="textblock"><p>A program using the hwloc C API (for instance with <span class="tt">hwloc-hello.c</span> presented in <a class="el" href="index.html#interface_example">API Example</a>) may be built with standard development tools. <span class="tt">pkg-config</span> provides easy ways to retrieve the required compiler and linker flags as described below, but it is not mandatory.</p> |
| 49 |
<h1 class="doxsection"><a class="anchor" id="useapi_gnumake"></a> |
| 50 |
Compiling on top of hwloc's C API with GNU Make</h1> |
| 51 |
<p>Here's an example of Makefile for building <span class="tt">hwloc-hello.c</span> with GNU Make:</p> |
| 52 |
<pre class="fragment">CFLAGS += $(shell pkg-config --cflags hwloc) |
| 53 |
LDLIBS += $(shell pkg-config --libs hwloc) |
| 54 |
|
| 55 |
hwloc-hello: hwloc-hello.c |
| 56 |
$(CC) hwloc-hello.c $(CFLAGS) -o hwloc-hello $(LDLIBS) |
| 57 |
</pre><h1 class="doxsection"><a class="anchor" id="useapi_cmake"></a> |
| 58 |
Compiling on top of hwloc's C API with CMake</h1> |
| 59 |
<p>Here's an example de <span class="tt">CMakeLists.txt</span> which shows variables obtained from <span class="tt">pkg-config</span> and how to use them:</p> |
| 60 |
<pre class="fragment">cmake_minimum_required(VERSION 3.6) |
| 61 |
project(TEST_HWLOC C) |
| 62 |
|
| 63 |
include(FindPkgConfig) |
| 64 |
if(PKG_CONFIG_FOUND) |
| 65 |
pkg_search_module(HWLOC REQUIRED IMPORTED_TARGET hwloc) |
| 66 |
else(PKG_CONFIG_FOUND) |
| 67 |
message(FATAL_ERROR "FindHWLOC needs pkg-config program and PKG_CONFIG_PATH must contain the path to hwloc.pc file.") |
| 68 |
endif(PKG_CONFIG_FOUND) |
| 69 |
|
| 70 |
add_executable(hwloc-hello hwloc-hello.c) |
| 71 |
target_link_libraries(hwloc-hello PRIVATE PkgConfig::HWLOC) |
| 72 |
</pre><p>The project may be built with: </p><pre class="fragment">cmake -B build |
| 73 |
cmake --build build --verbose |
| 74 |
</pre><p>The built binary is then available under <span class="tt">build/hwloc-hello</span>. </p> |
| 75 |
</div></div><!-- contents --> |
| 76 |
</div><!-- PageDoc --> |
| 77 |
<!-- start footer part --> |
| 78 |
<hr class="footer"/><address class="footer"><small> |
| 79 |
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.15.0 |
| 80 |
</small></address> |
| 81 |
</div><!-- doc-content --> |
| 82 |
</body> |
| 83 |
</html> |