Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "bare" C and C++ build tips docs #1371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

asinghvi17
Copy link

Adds brief descriptions of how to do "bare" (no build system) C and C++ builds - just to show where things should go.

Adds brief descriptions of how to do "bare" (no build system) C and C++ builds - just to show where things should go.
@asinghvi17 asinghvi17 changed the title Update build_tips.md Update build tips docs Feb 27, 2025
@asinghvi17 asinghvi17 changed the title Update build tips docs Add "bare" C and C++ build tips docs Feb 27, 2025
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me

Out of curiosity, what is the immediate motivation for this, did you have to package something for Yggdrasil were this was necessary?

@fingolfin fingolfin requested a review from giordano March 21, 2025 10:18
# adjust your `cd` appropriately
cd $WORKSPACE/srcdir/hello
mkdir -p ${libdir}
$CXX -shared -std=c++11 -O3 -fPIC -o ${libdir}/libhello.${dlext} src/hello.cpp # you may want to edit the `std` flag, for exampLE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$CXX -shared -std=c++11 -O3 -fPIC -o ${libdir}/libhello.${dlext} src/hello.cpp # you may want to edit the `std` flag, for exampLE
$CXX -shared -std=c++11 -O3 -fPIC -o ${libdir}/libhello.${dlext} src/hello.cpp # you may want to edit the `std` flag, for example

## C builds

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).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to give the impression that this are the exact commands one shall run, it's rather to give an idea (I can't say how many times people take these instructions almost verbatim rather than as indication)

Suggested change
As a high-level example:

## C++ builds

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
As a high-level example:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants