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

Unable to run the go.file #24

Closed
Sapna100 opened this issue Aug 28, 2020 · 11 comments
Closed

Unable to run the go.file #24

Sapna100 opened this issue Aug 28, 2020 · 11 comments

Comments

@Sapna100
Copy link

I am facing the below issue when i try to run the go.file on Windows

PFB the error:

D:\Go_Folder\src\sap_con>go run sap_connection.go #github.com/sap/gorfc/gorfc ....\pkg\mod\github.com\sap\[email protected]\gorfc\gorfc.go:52:10: fatal error: sapnwrfc.h:
No such file or directory #include <sapnwrfc.h> compilation terminated.

Please suggest.

@bsrdjan
Copy link
Contributor

bsrdjan commented Aug 28, 2020

The error message shows that SAP NWRFC SDK include files are not found.

Is SAP NWRFC SDK installed on your system and in which folder?

The GO should be informed about the location of include files, like described in README: https://github.com/SAP/gorfc#install-gorfc

Alternatively you can clone the repository and adapt #cgo windows options in gorfc.go

#cgo windows CFLAGS: -IC:/Tools/nwrfcsdk/include/
#cgo windows LDFLAGS: -LC:/Tools/nwrfcsdk/lib/ -lsapnwrfc -llibsapucum

@Sapna100
Copy link
Author

Sapna100 commented Aug 31, 2020

I am trying to run the commands using git bash. Facing the below error while running the command "go get github.com/sap/gorfc"

Error

$ go get github.com/sap/gorfc
#github.com/sap/gorfc
D:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsapnwrfc
D:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -llibsapucum
collect2.exe: error: ld returned 1 exit status
#github.com/sap/gorfc
In file included from D:\Software\nwrfcsdk\nwrfcsdk/include/sapnwrfc.h:7,
from github.com\sap\gorfc\gorfc.go:62:
D:\Software\nwrfcsdk\nwrfcsdk/include/sapucrfc.h:705:5: warning: 'align' attribute directive ignored [-Wattributes]
typedef __declspec(align(16)) SAP_SRAW platform_max_t[16];
^~~~~~~
In file included from github.com\sap\gorfc\gorfc.go:62:
D:\Software\nwrfcsdk\nwrfcsdk/include/sapnwrfc.h:29: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning (disable : 4267) // disable warning: conversion from 'size_t' to 'const unsigned int'

In file included from D:\Software\nwrfcsdk\nwrfcsdk/include/sapnwrfc.h:7,
from github.com\sap\gorfc\gorfc.go:62:
D:\Software\nwrfcsdk\nwrfcsdk/include/sapucrfc.h:1427:27: warning: 'unicodeId' defined but not used [-Wunused-variable]
static SAP_RAW SAP_UNUSED unicodeId[] = cR("@(#) Unicode");

@bsrdjan
Copy link
Contributor

bsrdjan commented Aug 31, 2020

The error log shows that SAP NWRFC SDK libraries are not found.

In which folder is SAP NWRFC SDK installed on your system and did you set the env variables following the installation steps ?

The dir $CGO_LDFLAGS (or dir $env:CGO_LDFLAGS in PS) should show SAP NWRFC SDK libraries. Could you please check that on your system?

@Sapna100
Copy link
Author

Sapna100 commented Aug 31, 2020

Env variables are set as below:
In user variable - SAPNWRFC_HOME is set to D:\Software\nwrfcsdk\nwrfcsdk
In system variable - Path added as D:\Software\nwrfcsdk\nwrfcsdk\lib

@bsrdjan
Copy link
Contributor

bsrdjan commented Aug 31, 2020

And CGO_LDFLAGS ?

The dir $CGO_LDFLAGS (or dir $env:CGO_LDFLAGS in PS) should show SAP NWRFC SDK libraries. Could you please check that on your system?

@Sapna100
Copy link
Author

Should i set the GCO_LDFLAGS in env variable?

I actually ran the below commands on git bash from readme document:
export CGO_CFLAGS="-I $SAPNWRFC_HOME/include"
export CGO_LDFLAGS="-L $SAPNWRFC_HOME/lib"
export CGO_CFLAGS_ALLOW=.*
export CGO_LDFLAGS_ALLOW=.*
go get github.com/stretchr/testify

and when i ran the command "go get github.com/sap/gorfc" facing the error as shown above.

@Sapna100
Copy link
Author

Sapna100 commented Sep 9, 2020

I have also tired the alternate method suggested.
Made the below changes in gorfc.go file:

#cgo windows CFLAGS: -ID:/Software/nwrfcsdk/nwrfcsdk/include
#cgo windows LDFLAGS: -LD:/Software/nwrfcsdk/nwrfcsdk/lib -lsapnwrfc -llibsapucum

PFB the error:
$ go run sap_connection.go
#github.com/sap/gorfc/gorfc
D:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsapnwrfc
D:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -llibsapucum
collect2.exe: error: ld returned 1 exit status
#github.com/sap/gorfc/gorfc
In file included from D:/Software/nwrfcsdk/nwrfcsdk/include/sapnwrfc.h:7,
from ....\pkg\mod\github.com\sap\[email protected]\gorfc\gorfc.go:52:
D:/Software/nwrfcsdk/nwrfcsdk/include/sapucrfc.h:705:5: warning: 'align' attribute directive ignored [-Wattributes]
typedef __declspec(align(16)) SAP_SRAW platform_max_t[16];
^~~~~~~
In file included from ....\pkg\mod\github.com\sap\[email protected]\gorfc\gorfc.go:52:
D:/Software/nwrfcsdk/nwrfcsdk/include/sapnwrfc.h:29: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning (disable : 4267) // disable warning: conversion from 'size_t' to 'const unsigned int'

In file included from D:/Software/nwrfcsdk/nwrfcsdk/include/sapnwrfc.h:7,
from ....\pkg\mod\github.com\sap\[email protected]\gorfc\gorfc.go:52:
D:/Software/nwrfcsdk/nwrfcsdk/include/sapucrfc.h:1427:27: warning: 'unicodeId' defined but not used [-Wunused-variable]
static SAP_RAW SAP_UNUSED unicodeId[] = cR("@(#) Unicode");

@ly020044
Copy link

I have the same problem, but env setting complete.
OS VERSION: windows 10
GO VERSION: 1.15.2

`C:\Users\John Li\go\pkg\mod\github.com\sap\[email protected]\gorfc>go build

github.com/sap/gorfc/gorfc

In file included from D:\nwrfcsdk\include/sapnwrfc.h:7,
from .\gorfc.go:52:
D:\nwrfcsdk\include/sapucrfc.h:705:5: warning: 'align' attribute directive ignored [-Wattributes]
typedef __declspec(align(16)) SAP_SRAW platform_max_t[16];
^~~~~~~
In file included from .\gorfc.go:52:
D:\nwrfcsdk\include/sapnwrfc.h:29: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning (disable : 4267) // disable warning: conversion from 'size_t' to 'const unsigned int'

In file included from D:\nwrfcsdk\include/sapnwrfc.h:7,
from .\gorfc.go:52:
D:\nwrfcsdk\include/sapucrfc.h:1427:27: warning: 'unicodeId' defined but not used [-Wunused-variable]
static SAP_RAW SAP_UNUSED unicodeId[] = cR("@(#) Unicode");`

@zen37
Copy link

zen37 commented Oct 18, 2020

OS VERSION: windows 10
GO VERSION: 1.15.2

exactly same errors like above

@bsrdjan
Copy link
Contributor

bsrdjan commented Oct 26, 2020

The Windows is not supported until #21 fixed

@bsrdjan
Copy link
Contributor

bsrdjan commented May 4, 2021

Closing due to the sunset of the project.

@bsrdjan bsrdjan closed this as completed May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants