Easy3D icon indicating copy to clipboard operation
Easy3D copied to clipboard

Compiling Easy3D as dynamic library

Open lizOnly opened this issue 2 years ago • 4 comments

Enabling the use of Easy3D in a dynamic library project.

lizOnly avatar Sep 01 '21 13:09 lizOnly

Thank you for your efforts in this pull request! It works perfectly on Mac and Linux, but it seems not possible to make it work on Windows without modifying the source code. As far I know, we'll have to make the following changes for Windows:

  • define a macro, e.g., EASY3D_API as
    #ifdef EASY3D_DYNAMIC_LIBRARY
    #define EASY3D_API __declspec(dllexport)
    #else
    #define EASY3D_API __declspec(dllimport)
    #endif
    
  • add EASY3D_API to the declarations of ALL the classes and functions that will be exported to the dynamic libraries. The involves modifying almost every file in Easy3D.

Do you know if there is an easier way that these can be done?

Besides, it will be better to introduce a CMake option, e.g., EASY3D_BUILD_DYNAMIC_LIBRARY in the main CMakeList file, so users can choose between static and dynamic.

LiangliangNan avatar Sep 02 '21 07:09 LiangliangNan

Thank you for replying. I did not consider Windows, and unfortunately, I don't know an easier way to do it for Windows. I think it will be good to introduce the CMake option for Easy3D as dynamic library for Linux and Mac users for now.

lizOnly avatar Sep 02 '21 18:09 lizOnly

I will have this issue on hold until an elegant solution is found. Maybe http://gcc.gnu.org/wiki/Visibility ...

LiangliangNan avatar Sep 10 '21 09:09 LiangliangNan

Some scenarios also need to use static libraries. You can make a switch later, and you can freely switch the compilation configuration of static libraries and dynamic libraries. That's even better!

ccworld1000 avatar Dec 16 '21 02:12 ccworld1000

Hi, Just to let you know that Easy3D now can be built as shared libraries. The latest code is in the dev branch: https://github.com/LiangliangNan/Easy3D/tree/dev I will merge it into the main branch after more tests. In case you use it and find issues, do please let me know.

I will close this pull request. Good luck with your research!

LiangliangNan avatar Nov 03 '22 17:11 LiangliangNan