You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update build_tips.md
Adds brief descriptions of how to do "bare" (no build system) C and C++ builds - just to show where things should go.
* Apply suggestions from code review
Co-authored-by: Mosè Giordano <765740+giordano@users.noreply.github.com>
---------
Co-authored-by: Mosè Giordano <765740+giordano@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/src/build_tips.md
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,36 @@ Example of packages using Rust:
127
127
128
128
The Rust toolchain currently used does not work with the `i686-w64-mingw32` (32-bit Windows) platform.
129
129
130
+
## C builds
131
+
132
+
If your library has no build system like Make, CMake, Meson, or Autoconf, you may need to use the C compiler directly. The C compiler is stored in the `CC` environment variable, and you can direct output to `libdir` (shared libraries) and `bindir` (executables).
133
+
As a high-level example:
134
+
135
+
```sh
136
+
# this assumes you are operating out of a Git source named `hello`
137
+
# adjust your `cd` appropriately
138
+
cd$WORKSPACE/srcdir/hello
139
+
mkdir -p ${libdir}# make sure the libdir is instantiated
140
+
${CC} -shared -o ${libdir}/libhello.${dlext} -fPIC hello.c # compile the library, save to `libdir`
141
+
```
142
+
143
+
This is simply compiling a single shared library, `libhello`, from `hello.c`.
144
+
145
+
## C++ builds
146
+
147
+
Similarly to C builds, sometimes your C++ libraries will not have a build system associated with them. The C++ compiler is stored in the `CXX` environment variable.
148
+
As a high-level example:
149
+
150
+
```sh
151
+
# this assumes you are operating out of a Git source named `hello`
152
+
# adjust your `cd` appropriately
153
+
cd$WORKSPACE/srcdir/hello
154
+
mkdir -p ${libdir}
155
+
$CXX -shared -std=c++11 -O3 -fPIC -o ${libdir}/libhello.${dlext} src/hello.cpp # you may want to edit the `std` flag, for example
156
+
```
157
+
158
+
This is simply compiling a single shared library, `libhello`, from `hello.cpp`.
159
+
130
160
## Editing files in the wizard
131
161
132
162
In the wizard, the `vim` editor is available for editing files. But, it doesn't leave any record in the build script. One generally needs to provide patch files or use something like `sed`. If a file needs patching, we suggest using `git` to add the entire worktree to a new repo, make the changes you need, then use `git diff -p` to output a patch that can be included alongside your build recipe.
0 commit comments