Closed Atsika closed 2 years ago
@Atsika you may used -I argument gived import search path for go tool compile
It doesn't fix the issue. First, I retrieved the package using:
go get golang.org/x/sys/windows
Then I tried to compile using the argument you specified:
PS> go tool compile -I C:\Users\user\go\pkg\mod\ .\custom.go
.\custom.go:6:2: could not import "golang.org/x/sys/windows": file not found
And as you can see, on the following screenshot, package is present:
it need a .a lib so, you need use command go tool compile -I C:\Users\user\go\pkg\windows_amd64 .\custom.go it is in readme examples.
go tool compile -I $GOPATH/pkg/`go env GOOS`_`go env GOARCH`/ -o test.o test1.go test2.go
I've read the README.md, however it's still unclear for me.
The command you suggested me won't work since this folder doesn't exist there.
Go is installed under C:\Program Files\Go\
on my VM, so the path would be : C:\Program Files\Go\pkg\windows_amd64
Trying go tool compile -I C:\Program Files\Go\pkg\windows_amd64 .\custom.go
gives the same error:
PS> go tool compile -I "C:\Program Files\Go\pkg\windows_amd64" .\custom.go
.\custom.go:6:2: could not import "golang.org/x/sys/windows": file not found
If I understand well, I need to compile the golang.org/x/sys/windows
first and then my object file.
Unfortunatly, I don't understand how to compile the windows
package.
@Atsika if you do not find $GOPATH/pkg/windows_amd64/golang.org/x/sys/windows, you can copy golang.org/x/sys/windows source code into your $GOPATH/src; then exec go install golang.org/x/sys/windows
What should be the output of go install golang.org/x/sys/windows
?
It will be install windows.a in $GOPATH/pkg/windows_amd64
mkdir -p D:\Data\Code\go\pkg\windows_amd64\golang.org\x\sys\
cp $WORK\b001\_pkg_.a D:\Data\Code\go\pkg\windows_amd64\golang.org\x\sys\windows.a
rm -r $WORK\b001\
D:\Data\Code\go\src>go install -a -x -v golang.org\x\sys\windows
Hey, this worked ! thank you for your support :smiley:
Does my loader need to register every external function I want to use ? Or is there a way to compile statically the external package in my object file ?
@Atsika if the function is used in your loader, it doesn‘t need to import.
in addition, you can load a library at the same times like examples
Hi,
I'm trying to compile a Go object that imports package
golang.org/x/sys/windows
.However I'm running in the following error:
Here is my code :
Here is the output of
go version
so you can replicate:Is there any special procedure to compile Go object files that import external packages ?
Thanks in advance.