Coder Social home page Coder Social logo

MacOS compilation about plug HOT 16 CLOSED

offa avatar offa commented on June 19, 2024
MacOS compilation

from plug.

Comments (16)

offa avatar offa commented on June 19, 2024 1

Seems these targets need some more work.

from plug.

j824h avatar j824h commented on June 19, 2024 1

Thanks!
Adding target_link_libraries worked with the right target specified. (237-libusb...j824h:plug:patch-1)

from plug.

offa avatar offa commented on June 19, 2024

CMake seems to find libusb correctly, so I wonder why the include is missing. Can you check whether the CMake variable libusb-1.0_INCLUDE_DIR points to a valid path containing libusb-1.0/libusb.h?

I'm also getting a ton of errors about old-style-casting and unsigned-conversions, which I've ignored using make -i

Do these warning come from a library header or plug? Clang should handle system includes correctly, but I have not experience on Mac OS.

from plug.

j824h avatar j824h commented on June 19, 2024

I had to add
include_directories(/usr/local/include)
in src/com/CMakeLists.txt, so that CMake can find libusb-1.0 installed by Homebrew.

Also for the root CMakeLists.txt, I found disabling -pedantic, -pedantic-errors, -Wold-style-cast helps.

from plug.

offa avatar offa commented on June 19, 2024

What does your libusb-1.0_INCLUDE_DIR show?

Regarding warnings: Did compilation fail otherwise? What errors are shown? CI builds include Clang too, but only on Linux.

from plug.

j824h avatar j824h commented on June 19, 2024

Include errors

-- Found libusb-1.0: /usr/local/Cellar/libusb/1.0.26/lib/libusb-1.0.dylib
I see that libusb-1.0_INCLUDE_DIR is /usr/local/include.

Still, make would complain.

/Users/j824h/Documents/plug/src/com/UsbComm.cpp:25:10: fatal error: 'libusb-1.0/libusb.h' file not found

Syntax errors

After include_directories(/usr/local/include), the errors come from the header.

In file included from /Users/j824h/Documents/plug/src/com/UsbComm.cpp:25:
/usr/local/include/libusb-1.0/libusb.h:168:15: error: use of old-style cast [-Werror,-Wold-style-cast]
_tmp.b8[1] = (uint8_t) (x >> 8);
^ ~~~~~~~~
/usr/local/include/libusb-1.0/libusb.h:169:15: error: use of old-style cast [-Werror,-Wold-style-cast]
_tmp.b8[0] = (uint8_t) (x & 0xff);
^ ~~~~~~~~~~
/usr/local/include/libusb-1.0/libusb.h:789:31: error: zero size arrays are an extension [-Werror,-Wzero-length-array]
uint8_t dev_capability_data[ZERO_SIZED_ARRAY];

... and so on.

Clang correctly cast errors for the non-C++ syntax in libusb.h, according to the flags provided in CMakeLists.txt
In the other way round, I started to wonder why CI could build.

from plug.

offa avatar offa commented on June 19, 2024

Still, make would complain.

But /usr/local/include contains libusb-1.0/libusb.h!? Well … than there's something broken here.

Relying on PkgConfig not supported on Mac?

Clang correctly cast errors for the non-C++ syntax in libusb.h, according to the flags provided in CMakeLists.txt
In the other way round, I started to wonder why CI could build.

Yes and no, the reported issues come from an external library (libusb) and those are treated as system headers, which aren't affected by warnings etc..

Including through include_directories() wont do this, but rather treat the headers as usual. You can test this (not a solution!):

include_directories(SYSTEM /usr/local/include)

I'm not sure whether this works on Mac Clang though.

To sum it up: Findlibusb-1.0.cmake isn't working correctly here (--> include not found).

from plug.

offa avatar offa commented on June 19, 2024

Can you try the 237-libusb_missing_header branch please? 🤦

from plug.

j824h avatar j824h commented on June 19, 2024

Clang correctly cast errors for the non-C++ syntax in libusb.h, according to the flags provided in CMakeLists.txt
In the other way round, I started to wonder why CI could build.

Yes and no, the reported issues come from an external library (libusb) and those are treated as system headers, which aren't affected by warnings etc..

Including through include_directories() wont do this, but rather treat the headers as usual. You can test this (not a solution!):

include_directories(SYSTEM /usr/local/include)

I'm not sure whether this works on Mac Clang though.

To sum it up: Findlibusb-1.0.cmake isn't working correctly here (--> include not found).

Oh, thanks for the clarification! (I got much left to know about this CMake...)

include_directories(SYSTEM /usr/local/include)

For now, adding this is all I need to build.

Can you try the 237-libusb_missing_header branch please? 🤦

I will keep tracking this!
Now make moves on to other targets referring to libusb.h and gives errors there.

from plug.

offa avatar offa commented on June 19, 2024

Thanks, so I can merge the branch. What are the other targets / errors?

from plug.

j824h avatar j824h commented on June 19, 2024
  • plug-communication-usb
    • UsbContext.cpp
    • UsbException.cpp
    • UsbDevice.cpp
  • plug-updater
    • MustangUpdater.cpp

All of those, excluding the tests.

from plug.

offa avatar offa commented on June 19, 2024

Next try: 237-libusb – both targets link libusb on this branch now.

from plug.

offa avatar offa commented on June 19, 2024

Great! Since you have the change already, could you submit a PR please?

from plug.

offa avatar offa commented on June 19, 2024

Changes merged into master. Are there any build issues left?

from plug.

j824h avatar j824h commented on June 19, 2024

In a Homebrew environment, there's a subtlety, that Qt5_DIR=/usr/local/opt/qt5/lib/cmake/Qt5 should be passed to CMake.
I do think the blame is on the package manager's choice not to install Qt in a default path.
Otherwise, 8d93d21 is working great with libusb-1.0 and googletest installed by Homebrew on MacOS.

from plug.

offa avatar offa commented on June 19, 2024

I'm going to close here since compilation works now. Feel free to reopen if there's an issue left. Thanks 👍

from plug.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.