Undeclared Identifiers when using C code in a Go Program -
I am trying to use a library downloaded from the IRIS website. There are options to create a dynamic and static library in Messeile. I have tried both topology with both types of library with CGO and I have failed.
This is my go code
package main / * #cgo CFLAGS: -I #Cago LDFALGS: -L. -libslink #include & lt; Libslink.h> * / Import ("c") func main () {C.sl_newslcd ()} and I have the following files in the directory:
ChangeLog config.o globmatch.o logging.c slplatform.c strutils.c Mekfail Dock gswap.c logging.o slplatform.h strutils.o Makefile.wat example gswap.o main.go slplatform.o unpack.c Makefile.win genutils. A Libslinkk2k4kdilib Msrekordkk Slutilskk Anpakkh Redme Ganutilsko Libslinkka Msrekordko Slutilsko Anpakko Reedmikmd Globmckk Libslinkkdilib Netvrkkk Sttefilekk Configkk Globmc .h libslink.h network.o statefile.o Here are my error messages: go build -v main.go import "C" Is not recommended before: if "C" is imported immediately before a comment, then the comment is called the introduction, which is used when compiling the C parts of the package. Then the solution is to remove the blank line between comment and import. It will not compile, however, because the lib prefix for the -l parameter is ignored. You must specify -lslink instead of -libslink . After all, I recommend keeping a library in a sub-folder instead of in the same directory as your .go files. Example example with the appropriate sub-folder for the slink:
package head // # cgo CFLages: -i lbslink // #ccd ldfalgs: -l libslink - Include Lollink // # & lt; Libslink.h> Import "c" func main () {c. SL_NUZLCD ()}
Comments
Post a Comment