riebl / vanetza

Open-source implementation of the ETSI C-ITS protocol stack
Other
204 stars 156 forks source link

Building Vanetza on Windows #128

Open HpLightcorner opened 3 years ago

HpLightcorner commented 3 years ago

Hi @riebl, Linked to our discussion: https://github.com/riebl/artery/issues/184

I am currently building Vanetza on Windows, I finally got everything to build except ASN1: https://github.com/riebl/vanetza/blob/15de29825e6e8c3f6a1a88c06e1a755e127ef657/vanetza/asn1/support/INTEGER.c#L114

It fails with:

[build] C:/_work/repos/artery/extern/vanetza/vanetza/asn1/support/INTEGER.c: In function 'INTEGER__dump':
[build] C:/_work/repos/artery/extern/vanetza/vanetza/asn1/support/INTEGER.c:156:9: error: expected ')' before 'PRIdMAX'
[build]   156 |      "%" ASN_PRIdMAX " (%s)", value, el->enum_name);
[build]       |         ^
[build]       |         )

It seems like a preprocessor error? If I got it right, this should somehow be replaced to the correct formatting-string: "%" ASN_PRIdMAX " (%s)" - for this example this should be: %i (%s) - right?

HpLightcorner commented 3 years ago

Found the issue... An include-statement was missing... I had to add #include <inttypes.h> to asn_system.h. However, I fail to link with errors coming from GeneralizedTime.c.

There are a lot of preprocessor-defines present to distinguish between platforms, so I got the following questions now:

Quite hard to find the missing link without fully understanding the code. Also, I assume that I can Ingnore all those warnings like _localtimer is implemented via localtime(), which may be not thread-safe?

riebl commented 3 years ago

I also think it is "safe" to ignore the warnings about thread safety. The ASN.1 code is either generated by asn1c or skeleton code provided by asn1c, i.e. manual changes are likely to get overwritten at some point. If changes are necessary, I have to incorporate them into CMake to always get properly patched generated code. Honestly speaking, I don't know if there are differences between CYGWIN and MINGW32. Regarding the setenv and unsetenv issue: This code is not actively used by Vanetza. Any stub implementation doing nothing would be an acceptable workaround from my point of view.

HpLightcorner commented 3 years ago

Hmm, fixing hat in CMake is then for sure necessary. I will focus a few days on getting the CMake Package down before patching Vanzeta for Windows Builds adding stub implementation, but that should be an easy fix.

khevessy commented 2 years ago

Hi @HpLightcorner,

I have some other issues building Vanetza on Windows. I am using MSVC, so you probably do not know, but as you also attempted this, did you by any chance come across similar issue? I have problems with CryptoPP library. https://github.com/riebl/vanetza/issues/169

Thanks, Karel

riebl commented 2 years ago

For Windows builds, I would try to use Conan for the build process. Handling all the library dependencies manually on Windows is no fun at all.