Compilation error with BASH for WIN 10

73 views
Skip to first unread message

Demetri

unread,
Mar 12, 2018, 4:01:01 PM3/12/18
to Wazuh mailing list
Hi,

I'm trying to compile the agent in BASH for Windows 10. I can get it to compile in my Ubuntu VM, but I would like to develop in windows. I don't want to shift around source files, exes, etc. Ideally, I was hoping to code in Visual Studio in Windows - but I suppose it'd be ok to compile with BASH (going to the mounted windows drive with my source). Any suggestions on developing in Windows would be appreciated.

Below is the error with BASH in WIN 10 the error is:

 Entering directory '/mnt/c/Users/Demetri/source/repos/wazuh/src'
    CC wazuh_db/schema_agents.o
<stdin>:1:33: warning: missing terminating " character
<stdin>:1:1: error: missing terminating " character
<stdin>:2:4: error: ‘SQL’ undeclared here (not in a function)
<stdin>:2:8: error: expected ‘,’ or ‘;’ before ‘Schema’
<stdin>:3:36: error: stray ‘@’ in program
<stdin>:12:40: warning: multi-character character constant [-Wmultichar]
<stdin>:12:48: warning: character constant too long for its type
<stdin>:15:1: error: unknown type name ‘CREATE’
<stdin>:15:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘INDEX’
<stdin>:15:15: error: unknown type name ‘INDEX’
<stdin>:17:1: error: unknown type name ‘CREATE’
<stdin>:17:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:17:14: error: unknown type name ‘IF’
<stdin>:20:40: warning: character constant too long for its type
<stdin>:20:49: warning: character constant too long for its type
<stdin>:20:61: warning: character constant too long for its type
<stdin>:20:72: warning: character constant too long for its type
<stdin>:34:1: error: unknown type name ‘CREATE’
<stdin>:34:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:34:14: error: unknown type name ‘IF’
<stdin>:35:1: error: unknown type name ‘CREATE’
<stdin>:35:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:35:14: error: unknown type name ‘IF’
<stdin>:36:1: error: unknown type name ‘CREATE’
<stdin>:36:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:36:14: error: unknown type name ‘IF’
<stdin>:37:1: error: unknown type name ‘CREATE’
<stdin>:37:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:37:14: error: unknown type name ‘IF’
<stdin>:38:1: error: unknown type name ‘CREATE’
<stdin>:38:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:38:14: error: unknown type name ‘IF’
<stdin>:40:1: error: unknown type name ‘CREATE’
<stdin>:40:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:40:14: error: unknown type name ‘IF’
<stdin>:42:40: warning: multi-character character constant [-Wmultichar]
<stdin>:42:48: warning: character constant too long for its type
<stdin>:43:45: warning: multi-character character constant [-Wmultichar]
<stdin>:43:51: warning: multi-character character constant [-Wmultichar]
<stdin>:57:1: error: unknown type name ‘CREATE’
<stdin>:57:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:57:14: error: unknown type name ‘IF’
<stdin>:66:1: error: unknown type name ‘CREATE’
<stdin>:66:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:66:14: error: unknown type name ‘IF’
<stdin>:67:1: error: unknown type name ‘CREATE’
<stdin>:67:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:67:14: error: unknown type name ‘IF’
<stdin>:69:1: error: unknown type name ‘PRAGMA’
<stdin>:69:21: error: ‘WAL’ undeclared here (not in a function)
<stdin>:71:1: error: unknown type name ‘CREATE’
<stdin>:71:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:71:14: error: unknown type name ‘IF’
<stdin>:77:40: warning: character constant too long for its type
<stdin>:77:51: warning: character constant too long for its type
<stdin>:77:63: warning: character constant too long for its type
<stdin>:77:74: warning: character constant too long for its type
<stdin>:77:92: warning: character constant too long for its type
<stdin>:80:1: error: unknown type name ‘CREATE’
<stdin>:80:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:80:14: error: unknown type name ‘IF’
<stdin>:98:1: error: unknown type name ‘CREATE’
<stdin>:98:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:98:14: error: unknown type name ‘IF’
<stdin>:100:1: error: unknown type name ‘CREATE’
<stdin>:100:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:100:14: error: unknown type name ‘IF’
<stdin>:118:1: error: unknown type name ‘CREATE’
<stdin>:118:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:118:14: error: unknown type name ‘IF’
<stdin>:130:1: error: unknown type name ‘CREATE’
<stdin>:130:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:130:14: error: unknown type name ‘IF’
<stdin>:146:1: error: unknown type name ‘CREATE’
<stdin>:146:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:146:14: error: unknown type name ‘IF’
<stdin>:148:1: error: unknown type name ‘CREATE’
<stdin>:148:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:148:14: error: unknown type name ‘IF’
<stdin>:151:44: warning: multi-character character constant [-Wmultichar]
<stdin>:151:51: warning: multi-character character constant [-Wmultichar]
<stdin>:151:58: warning: multi-character character constant [-Wmultichar]
<stdin>:151:65: warning: multi-character character constant [-Wmultichar]
<stdin>:160:1: error: unknown type name ‘CREATE’
<stdin>:160:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:160:14: error: unknown type name ‘IF’
<stdin>:162:1: error: unknown type name ‘CREATE’
<stdin>:162:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:162:14: error: unknown type name ‘IF’
<stdin>:196:1: error: unknown type name ‘CREATE’
<stdin>:196:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:196:14: error: unknown type name ‘IF’
<stdin>:198:1: error: unknown type name ‘CREATE’
<stdin>:198:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IF’
<stdin>:198:14: error: unknown type name ‘IF’
<stdin>:202:1: warning: missing terminating " character
<stdin>:202:1: error: missing terminating " character
Makefile:678: recipe for target 'wazuh_db/schema_agents.o' failed
make[1]: *** [wazuh_db/schema_agents.o] Error 1
make[1]: Leaving directory '/mnt/c/Users/Demetri/source/repos/wazuh/src'
Makefile:492: recipe for target 'winagent' failed
make: *** [winagent] Error 2

Borja Arroba

unread,
Mar 14, 2018, 7:36:41 AM3/14/18
to Wazuh mailing list
Hi demetri

I tried installing Ubuntu Shell on windows 10 and compiled with TARGET=winagent without any problems.
Have you followed the steps described in the documentation?

https://documentation.wazuh.com/2.1/installation-guide/installing-wazuh-agent/wazuh_agent_sources.html?highlight=compile#installing-windows-agent

If so, can you compile without making any changes?

I have taken the following steps:
  1. Install Ubuntu Shell from Windows Store
  2. Enable "Windows Subsystem for Linux" from Windows Features
  3. Download wazuh from Github and compile with:
# make clean
# make TARGET=winagent DEBUG=true


Hope its helps
Best regards
Borja Arroba

Demetri

unread,
Mar 14, 2018, 12:41:11 PM3/14/18
to Wazuh mailing list
Hi, thanks for the response.

I did follow the steps that you outlined. For some reason, my windows bash shell had an issue in the make file with line 678 when it is performing the 'cat' and '\n'. I changed to '\r\n' and it compiles. I should probably change my bash profile to use linux style line endings (need to figure out how to do that).

I've got the project open in Visual Studio 2017 and compiled with the DEBUG option ('make TARGET=winagent DEBUG=true'), but GDB can't hit any breakpoints for ossec-agent.exe in win_agent.c. It's telling me it was built without symbols. I'm just trying to understand the project, and I find by stepping through with my debugger really helps.

I configured Visual Studio 2017 using the following 'https://blogs.msdn.microsoft.com/vcblog/2017/07/19/using-mingw-and-cygwin-with-visual-cpp-and-open-folder/' and can get a project from scratch to debug gcc compiled C code with GDB.

Any suggestions?

Thanks.

Demetri

unread,
Mar 14, 2018, 1:48:08 PM3/14/18
to Wazuh mailing list
Ah, I figured out the issue. It appears Wazuh builds in 32-bit and I had configured my IDE debugger for 64-bit. Once I changed the targets I can (finally) step into the code.
Reply all
Reply to author
Forward
0 new messages