Cgo include archive .a file
I'm trying to use an external C library with my Go program.
I have tried the following:
package cgoexample
/*
#include <stdio.h>
#include <stdlib.h>
#cgo CFLAGS: -I/Users/me/somelib/include
#cgo LDFLAGS: /Users/me/somelib/libhello.a
#include "stinger.h"
void myprint(char* s) {
printf("%s", s);
}
*/
import "C"
import "unsafe"
//... more here
In the /Users/me/somelib/include there is the .h file and in libhello.a
there is the .o file (I checked using the ar command) that has the defined
functions that are in the .h file.
It seems that the .h files are being linked OK, but it doesn't look like
the archive file is being linked. I keep getting these:
warning: 'some_method_in_my_h_file" declared 'static' but never defined
And these warnings are being treated as errors. Regardless, they should be
implemented in the archive file, so I'm confused what I'm doing wrong
here.
When I run go build and gun run.
I have a feeling my #cgo command is invalid (I'm not C expert),
No comments:
Post a Comment