bububa / xgboost-go

xgboost go wrapper for c_api
Apache License 2.0
22 stars 7 forks source link

invalid flag in #cgo LDFLAGS: -fopenmp #1

Closed beijinggao closed 6 years ago

beijinggao commented 6 years ago

你好,请问一下在执行的时候 openmp 报非法:invalid flag in #cgo LDFLAGS: -fopenmp 您在使用的时候没遇到吗?如何解决呢

bububa commented 6 years ago

@gao8954 你装openmp了吗?我没遇到这个错误。是不是你的gcc有问题?

beijinggao commented 6 years ago

直接用g++命令编译可正常编译通过,也是奇怪了

beijinggao commented 6 years ago

@bububa 你好在使用最新的xgboost的时候 发现其中 rabit 的头文件 c_api.h 稍微改变了一种写法 如下:

ifndef RABIT_C_APIH

define RABIT_C_APIH

ifdef __cplusplus

define RABIT_EXTERN_C extern "C"

include

else

include

endif

if defined(_MSC_VER) || defined(_WIN32)

define RABIT_DLL RABIT_EXTERN_C __declspec(dllexport)

else

define RABIT_DLL RABIT_EXTERN_C

endif

/! \brief rabit unsigned long type / typedef unsigned long rbt_ulong; // NOLINT(*)

/*!

在您库中的rabit c_api.h 如下:

ifndef RABIT_C_APIH

define RABIT_C_APIH

ifdef __cplusplus

extern "C" {

include

else

include

endif

/! \brief rabit unsigned long type / typedef unsigned long rbt_ulong; // NOLINT(*)

/*!

仔细对比了一下其实没有啥本质区别 。但在使用你这个版本的头文件时就可以顺利运行,使用他的那个就会报 xgboost/include/rabit/c_api.h:35:11: error: expected '=', ',', ';', 'asm' or 'attribute' before 'void' RABIT_DLL void RabitInit(int argc, char *argv[]); ^ xgboost/include/rabit/c_api.h:41:11: error: expected '=', ',', ';', 'asm' or 'attribute' before 'void' RABIT_DLL void RabitFinalize(); ^ xgboost/include/rabit/c_api.h:44:11: error: expected '=', ',', ';', 'asm' or 'attribute' before 'int' RABIT_DLL int RabitGetRank(); ^ xgboost/include/rabit/c_api.h:47:11: error: expected '=', ',', ';', 'asm' or 'attribute' before 'int' RABIT_DLL int RabitGetWorldSize();

这样的错误,但是我发现最新版本的xgboost 的c_api.h的头文件实现方式和最新版的rabit c_api.h的风格是一样的 使用的时候 就没有这样的问题,您有啥建议吗?是什么原因导致的?

xuuj commented 6 years ago

@gao8954 我也遇到了同样问题 -fopenmp 请问是如何解决的

beijinggao commented 6 years ago

@xuuj go 的版本问题 有些 CFLAGS 没被加进去 ,试了几个版本 有的可以