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

Link liboqs statically #25

Closed
stv0g opened this issue Jun 6, 2023 · 4 comments
Closed

Link liboqs statically #25

stv0g opened this issue Jun 6, 2023 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@stv0g
Copy link

stv0g commented Jun 6, 2023

Does liboqs-go support static linking against liboqs?

I would like to build a statically linked Go executable without external depdendencies..

@vsoftco vsoftco self-assigned this Jul 5, 2023
@vsoftco vsoftco added the question Further information is requested label Jul 5, 2023
@stv0g
Copy link
Author

stv0g commented Aug 4, 2023

Here is an example as used by go-rosenpass: cunicu/go-rosenpass@fb93e83

@vsoftco
Copy link
Member

vsoftco commented Aug 4, 2023

@stv0g Thanks, I'll look into it this week

@vsoftco
Copy link
Member

vsoftco commented Oct 30, 2023

@stv0g The only way to link statically is a bit hacky.

In the cgo preamble of oqs.go, immediately after the line

#cgo pkg-config: liboqs
add the line #cgo LDFLAGS: /usr/local/liboqs.a (of course with the path corresponding to your location of liboqs.a). Make sure you don't add any additional new line(s).

Next, comment (add a # in front of) the last line of .config/liboqs.pc (the line starting with Libs:), i.e.,

Libs: -L${LIBOQS_LIB_DIR} -loqs

Finally, do a go clean -cache to force pkg-config to use the updated liboqs.pc.

As far as I know, there's no elegant way of statically linking by only modifying the liboqs.pc file.

@vsoftco vsoftco closed this as completed Oct 30, 2023
@vsoftco vsoftco reopened this Dec 1, 2023
@vsoftco
Copy link
Member

vsoftco commented Mar 27, 2024

Fixed by #37

@vsoftco vsoftco closed this as completed Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants