1

I am trying to Build the Hadoop 2.7.1 Sources in a Windows Server 2012 using Visual Studio Professional 2015.

The build of the winutils project failed, because an error in the libwinutils.c file. I installed the required software and set all of the environment variables. More or less I followed the directions from here: Hadoop on Windows Building/ Installation Error

I commented out a line of the code and replace it as it can be seen below. Basically, I just stringify the "WSCE_CONFIG_DIR" and the "WSCE_CONFIG_FILE" but I removed the use of the macro that converts the strings to wide character, and it worked. But I really want to know why is the original code not working.

#define WIDEN_STRING(x) WIDEN_STRING_(x)
#define WIDEN_STRING_(x) L ## x
#define STRINGIFY(x) STRINGIFY_(x)
#define STRINGIFY_(x) #x


#pragma message("WSCE config is " STRINGIFY(WSCE_CONFIG_DIR) "\\"  STRINGIFY(WSCE_CONFIG_FILE))
//const WCHAR* wsceConfigRelativePath = WIDEN_STRING(STRINGIFY(WSCE_CONFIG_DIR)) L"\\" WIDEN_STRING(STRINGIFY(WSCE_CONFIG_FILE));
const WCHAR* wsceConfigRelativePath = STRINGIFY(WSCE_CONFIG_DIR) "\\" STRINGIFY(WSCE_CONFIG_FILE);

Any comment would be highly appreciated.

Kind Regards, Paul

Community
  • 1
  • 1
Playing With BI
  • 411
  • 1
  • 9
  • 20
  • What is the exact error message you get (if multiple, take first one), and for which lines of code? – V-R May 02 '16 at 15:32
  • Hi @V-R, thanks for your quick response. The problematic line is this one: `code const WCHAR* wsceConfigRelativePath = WIDEN_STRING(STRINGIFY(WSCE_CONFIG_DIR)) L"\\" WIDEN_STRING(STRINGIFY(WSCE_CONFIG_FILE)); ` , In the error list: identifier "L" is undefined. Expected a ';' . Building errors are the same: C2065: 'L': undeclared identifier. C2099: Initializer is not a constant. C2143: syntax error: missing ';' before 'string' – Playing With BI May 02 '16 at 19:59

3 Answers3

4

I've just had this exact problem, and, after digging, here's the work-around. (I'm building 2.7.2, but I assume 2.7.1 isn't too different). The initial problem is that WSCE_CONFIG_DIR and WSCE_CONFIG_FILE aren't defined. Normally they come from the project's preprocessor definitions and have the values $(WsceConfigDir) and $(WsceConfigFile), ie are copies of these environment variables. When building Hadoop using the .pom's these are set by \hadoop-2.7.2-src\hadoop-common-project\hadoop-common\pom.xml from the configuration values wsce.config.dir and wsce.config.file earlier in this file. The values from the .pom are ../etc/hadoop and wsce-site.xml. To get round the problem I replaced $(WsceConfigDir) and $(WsceConfigFile) with these values in the libwinutils Preprocessor definitions.

Jon Roach
  • 87
  • 4
  • Hi Jon, thanks for your answer. Actually my workaround was just to avoid to call the macro WIDEN_STRING. It seems to not work properly when you pass a variable instead of a literal string. Example WIDEN_STRING(Variable_X) -- > don't work. WIDEN_STRING("Hi everybody") --> works. I think that`s the reason why your solution also works, but the variables WSCE_CONFIG_DIR and WSCE_CONFIG_FILE are defined, look at the winutils project properties --> C/C++ --> Preprocessor --> Preprocessor Definitions and you will find them. – Playing With BI May 22 '16 at 11:57
1

This question was posted a year ago.

I am not sure the guy who asked this question solved this issue or not.

However, for someone who comes here because of the same error, I post how I have solved.

First of all, I have done steps what tiho's answer below link.

Hadoop on Windows Building/ Installation Error

and then I changed the order of code in libwinutils.c like below.

(libwinutils.c located in \hadoop-common-project\hadoop-common\src\main\winutils)

I guess the order of code matters to build with Window SDK 7.1 cmd.

revised: (revised one more makes sense though)

#define WIDEN_STRING_(x) L ## x
#define WIDEN_STRING(x) WIDEN_STRING_(x)
#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_(x)

original:

#define WIDEN_STRING(x) WIDEN_STRING_(x)
#define WIDEN_STRING_(x) L ## x
#define STRINGIFY(x) STRINGIFY_(x)
#define STRINGIFY_(x) #x

and I executed 'mvn package -Pdist,native-win -DskipTests' command.

JasonRho
  • 106
  • 5
  • 1
    I solved it but I cannot remember how therefore I cannot mark your answer as the solution. Anyway, after this time I strongly recommend to compile Hadoop in a Unix environment. – Playing With BI Nov 30 '17 at 22:17
0

Please Change the Code as Below (it worked for me while building HADOOP-2.10.0 in Windows 10)

#include <Ntdsapi.h>
#include <malloc.h>

#define WIDEN_STRING(x)
#define STRINGIFY_(x)



#pragma message("WSCE config is " STRINGIFY(WSCE_CONFIG_DIR) "\\" STRINGIFY(WSCE_CONFIG_FILE))
const WCHAR* wsceConfigRelativePath = WIDEN_STRING(STRINGIFY(WSCE_CONFIG_DIR)) L"\\" WIDEN_STRING(STRINGIFY(WSCE_CONFIG_FILE));