HaplyHaptics / chai3d

The Open Source Haptic Framework with Haply devices support
http://www.chai3d.org
Other
3 stars 0 forks source link

Building Chai3d for Windows #1

Closed gabepierng closed 5 years ago

gabepierng commented 5 years ago

I'm currently working on building and compiling on a windows machine. However, I am getting caught up after cmake. Running cmake is successful (output logs attached), and it generates the VC++ project files needed for Visual Studio.

However, when I open those in VS and attempt to build them, the build fails as the linker cannot locate one of the libraries.

Error   382 error LNK1104: cannot open file '..\..\external\github-HaplyHaptics-Haply-API-cpp\Debug\haply-api-cpp.lib'

The VS build did generate a chai3d.lib file in ....\Debug, so that part is at least working correctly.

Also not sure if this is out of scope and/or better suited for chai3d github, but it seems to be an issue with the VS build instructions the CMake process is outputting

CMakeOutput.log

ChristianFrisson commented 5 years ago

Hi @gabepierng , thanks for your report!

chai3d and haply-api-cpp are meant to be compiled as static libraries. Here in your case, the compiler is looking for exported symbols in a .lib file that to compile against a .dll dynamic library. See a similar issue here.

Could you clear the cmake cache and set cmake flag BUILD_SHARED_LIBS to off, and try to rebuild?

gabepierng commented 5 years ago

I added a line to explicitly set BUILD_SHARED_LIBS off. I was actually able to fix the issue a little earlier. When I was building it in VS, there was also an error ambiguous symbol <byte>. This was discussed here. Though VS recognized it as Haply::byte if I hovered the cursor over it, they recommended explicitly qualifying it as Haply::byte instead of just byte in the function call where it was located.

Before

void WjwwoodSerial::readBytes(std::vector<byte>& in_data)

After

void WjwwoodSerial::readBytes(std::vector<Haply::byte>& in_data)

After this, VS built the static library just fine and it all built successfully For reference, running Visual Studio 2013

ChristianFrisson commented 5 years ago

Well spotted for both fixes!

I have updated https://github.com/HaplyHaptics/Haply-API-cpp/commit/8d1b3543ccc3482338de126ee8e93bffd347bc21 and HaplyHaptics chai3d https://github.com/HaplyHaptics/chai3d/commit/f9965800cb13d115cb55d6346bcde9226a43a33f with your fixes. Compiles and runs on Linux.

Is building on Windows now successful your side? If so, we can close this issue.

gabepierng commented 5 years ago

Yup, it is building successfully in Windows on my side now. I can go ahead and close the issue. Thanks!