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

Porting to Windows #1

Open
Th3oph1l opened this issue Sep 15, 2021 · 1 comment
Open

Porting to Windows #1

Th3oph1l opened this issue Sep 15, 2021 · 1 comment

Comments

@Th3oph1l
Copy link

Th3oph1l commented Sep 15, 2021

Hi,

has someone succesfully ported the library to windows?
I had to switch from linux to windows so i tried to use the binary form from the myolinux_1.1.0_x86_64.tar file.

I downloaded and extracted into my project folder, renamed the folder to "myolinux" and included it into my project with cmake as follows:

target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/myolinux/include)
target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/myolinux/lib/libmyolinux.so)

without cmake throwing errors, so I can do:

#include "myolinux/myoclient.h"
#include "myolinux/serial.h"

and the compiler finds the files but then i get houndreds of errors from "bleapi.h" as:

\myolinux\bleapi.h(20): error C2079: '__packed__' uses undefined struct 'myolinux::bled112::__attribute__'
\myolinux\bleapi.h(20): error C2146: syntax error: missing ';' before identifier 'Header'
\myolinux\bleapi.h(20): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(21): error C2275: 'uint8_t': illegal use of this type as an expression
de\myolinux\bleapi.h(21): note: see declaration of 'uint8_t'
\myolinux\bleapi.h(21): error C2146: syntax error: missing ')' before identifier 'length1'
\myolinux\bleapi.h(21): error C2059: syntax error: 'constant'
\myolinux\bleapi.h(22): error C2143: syntax error: missing ';' before ':'
\myolinux\bleapi.h(22): error C2059: syntax error: ':'
\myolinux\bleapi.h(22): error C2059: syntax error: 'constant'
\myolinux\bleapi.h(23): error C2143: syntax error: missing ';' before ':'
\myolinux\bleapi.h(23): error C2059: syntax error: ':'
\myolinux\bleapi.h(23): error C2059: syntax error: 'constant'
\myolinux\bleapi.h(29): error C2270: 'length': modifiers not allowed on nonmember functions
\myolinux\bleapi.h(30): error C2065: 'length1': undeclared identifier
\myolinux\bleapi.h(35): error C2061: syntax error: identifier 'getHeader'
\myolinux\bleapi.h(36): error C2143: syntax error: missing ';' before '{'
\myolinux\bleapi.h(36): error C2447: '{': missing function header (old-style formal list?)
\myolinux\bleapi.h(57): error C2146: syntax error: missing ';' before identifier 'SystemReset'
\myolinux\bleapi.h(57): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(58): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(58): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(58): error C2059: syntax error: ';'
\myolinux\bleapi.h(62): error C2146: syntax error: missing ';' before identifier 'SystemResetResponse'
\myolinux\bleapi.h(62): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(63): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(63): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(63): error C2059: syntax error: ';'
\myolinux\bleapi.h(64): error C2059: syntax error: '}'
\myolinux\bleapi.h(64): error C2143: syntax error: missing ';' before '}'
\myolinux\bleapi.h(66): error C2146: syntax error: missing ';' before identifier 'SystemHello'
\myolinux\bleapi.h(66): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(67): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(67): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(67): error C2059: syntax error: ';'
\myolinux\bleapi.h(68): error C2059: syntax error: '}'
\myolinux\bleapi.h(68): error C2143: syntax error: missing ';' before '}'
\myolinux\bleapi.h(70): error C2146: syntax error: missing ';' before identifier 'SystemHelloResponse'
\myolinux\bleapi.h(70): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(71): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(71): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(71): error C2059: syntax error: ';'
\myolinux\bleapi.h(72): error C2059: syntax error: '}'
\myolinux\bleapi.h(72): error C2143: syntax error: missing ';' before '}'
\myolinux\bleapi.h(74): error C2146: syntax error: missing ';' before identifier 'SystemAddressGet'
\myolinux\bleapi.h(74): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(75): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(75): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(75): error C2059: syntax error: ';'
\myolinux\bleapi.h(76): error C2059: syntax error: '}'
\myolinux\bleapi.h(76): error C2143: syntax error: missing ';' before '}'
\myolinux\bleapi.h(78): error C2146: syntax error: missing ';' before identifier 'SystemAddressGetResponse'
\myolinux\bleapi.h(78): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(79): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(79): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(79): error C2059: syntax error: ';'
\myolinux\bleapi.h(81): error C2059: syntax error: '}'
\myolinux\bleapi.h(81): error C2143: syntax error: missing ';' before '}'
\myolinux\bleapi.h(83): error C2146: syntax error: missing ';' before identifier 'SystemRegWrite'
\myolinux\bleapi.h(83): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(84): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(84): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(84): error C2059: syntax error: ';'
\myolinux\bleapi.h(87): error C2059: syntax error: '}'
\myolinux\bleapi.h(87): error C2143: syntax error: missing ';' before '}'
\myolinux\bleapi.h(89): error C2146: syntax error: missing ';' before identifier 'SystemRegWriteResponse'
\myolinux\bleapi.h(89): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(90): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(90): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(90): error C2059: syntax error: ';'
\myolinux\bleapi.h(92): error C2059: syntax error: '}'
\myolinux\bleapi.h(92): error C2143: syntax error: missing ';' before '}'
\myolinux\bleapi.h(94): error C2146: syntax error: missing ';' before identifier 'SystemRegRead'
\myolinux\bleapi.h(94): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(95): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(95): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(95): error C2059: syntax error: ';'
\myolinux\bleapi.h(97): error C2059: syntax error: '}'
\myolinux\bleapi.h(97): error C2143: syntax error: missing ';' before '}'
\myolinux\bleapi.h(99): error C2146: syntax error: missing ';' before identifier 'SystemRegReadResponse'
\myolinux\bleapi.h(99): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(100): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(100): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(100): error C2059: syntax error: ';'
\myolinux\bleapi.h(103): error C2059: syntax error: '}'
\myolinux\bleapi.h(103): error C2143: syntax error: missing ';' before '}'
\myolinux\bleapi.h(105): error C2146: syntax error: missing ';' before identifier 'SystemGetCounters'
\myolinux\bleapi.h(105): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\myolinux\bleapi.h(106): error C2065: 'cls': undeclared identifier
\myolinux\bleapi.h(106): error C2065: 'cmd': undeclared identifier
\myolinux\bleapi.h(106): error C2059: syntax error: ';'
\myolinux\bleapi.h(107): error C2059: syntax error: '}'
\myolinux\bleapi.h(107): error C2143: syntax error: missing ';' before '}'

and many more...

I don't know if it's not possible to import the binary form as i did or if i need to build from source on windows or what the problem is exactly - so any help is highly appreciated.

@brokenpylons
Copy link
Owner

brokenpylons commented Oct 28, 2021

I think the problem is that I used __attribute__((__packed__)) which is not supported on the MSVC compiler. It should be easy to fix by replacing PACKED in the bleapi.h with #pragma pack(push, 1) at the top and #pragma pack(pop) at the bottom of each struct definition (that is currently marked as PACKED).

Once you fix that there might also be some issues in the serial.cpp file as it uses Unix specific libraries to communicate over the serial port. You can re-implement this class using the Windows library. The rest of the code should compile without any problems though, because it doesn't have any external dependencies.

It would be easier if you used the GCC compiler (using Cygwin), in that case I expect the modifications would not be needed.

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

2 participants