File: a00366.html

package info (click to toggle)
hwloc 2.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,496 kB
  • sloc: ansic: 61,022; xml: 13,559; sh: 7,352; makefile: 2,150; javascript: 879; cpp: 93; sed: 5
file content (79 lines) | stat: -rw-r--r-- 3,694 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Hardware Locality (hwloc): Compiling software on top of hwloc&#39;s C API</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Hardware Locality (hwloc)<span id="projectnumber">&#160;2.12.2</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div><div class="header">
  <div class="headertitle"><div class="title">Compiling software on top of hwloc's C API</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>A program using the hwloc C API (for instance with <code>hwloc-hello.c</code> presented in <a class="el" href="index.html#interface_example">API Example</a>) may be built with standard development tools. <code>pkg-config</code> provides easy ways to retrieve the required compiler and linker flags as described below, but it is not mandatory.</p>
<h1><a class="anchor" id="useapi_gnumake"></a>
Compiling on top of hwloc's C API with GNU Make</h1>
<p>Here's an example of Makefile for building <code>hwloc-hello.c</code> with GNU Make:</p>
<pre class="fragment">CFLAGS += $(shell pkg-config --cflags hwloc)
LDLIBS += $(shell pkg-config --libs hwloc)

hwloc-hello: hwloc-hello.c
        $(CC) hwloc-hello.c $(CFLAGS) -o hwloc-hello $(LDLIBS)
</pre><h1><a class="anchor" id="useapi_cmake"></a>
Compiling on top of hwloc's C API with CMake</h1>
<p>Here's an example de <code>CMakeLists.txt</code> which shows variables obtained from <code>pkg-config</code> and how to use them:</p>
<pre class="fragment">cmake_minimum_required(VERSION 3.6)
project(TEST_HWLOC C)

include(FindPkgConfig)
if(PKG_CONFIG_FOUND)
  pkg_search_module(HWLOC REQUIRED IMPORTED_TARGET hwloc)
else(PKG_CONFIG_FOUND)
  message(FATAL_ERROR "FindHWLOC needs pkg-config program and PKG_CONFIG_PATH must contain the path to hwloc.pc file.")
endif(PKG_CONFIG_FOUND)

add_executable(hwloc-hello hwloc-hello.c)
target_link_libraries(hwloc-hello PRIVATE PkgConfig::HWLOC)
</pre><p>The project may be built with: </p><pre class="fragment">cmake -B build
cmake --build build --verbose
</pre><p>The built binary is then available under <code>build/hwloc-hello</code>. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>