Skip to content

Linking with static library #40

Answered by edubart
rprata asked this question in Q&A
Discussion options

You must be logged in to vote

It is possible, using a dynamic or static library shoud be the same, you need to import its C functions, see how to do that in the C interoperability section in the overview.

As an example, suppose you have mylib.a and mylib.h in the current folder, that declares the function mylib_func:

## cinclude 'mylib.h'
## linklib 'mylib'
## cflags '-I. -L.' -- tells the C compiler to look for include and library files in the current folder 
local function mylib_func() <cimport, nodecl> end
mylib_func() -- call the library function

Also related issues with similar question are #32 and #30.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by edubart
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #40 on December 24, 2020 13:53.