3 ms·
>I managed to write the whole library without a single #ifdef! Generates Linux .so, OS X .dylib, and Windows DLLs. Amazing! Could you expand on how you are doi
by CuttlefishXXX 11y ago
>I managed to write the whole library without a single #ifdef! Generates Linux .so, OS X .dylib, and Windows DLLs. Amazing!
Could you expand on how you are doing this? You're still using a Makefile or a similar tool with some kind of platform detection for the build itself, right?
- flohofwoe 11y agoNot sure whether the parent does it like this, but you can use cmake to describe the build, and then (for instance) run cmake --build to build the project in a 'cross-platform' way using the platform's native compiler toolchain, it works the same on Windows, OSX and Linux. I think what the parent meant with 'no #ifdefs' is that the C++11 std lib comes with more modules that make a lot of platform-specific code-paths unnecessary (for instance std::thread, std::atomic for threading, and std::chrono for high-resolution time-measuring).
- tonyarkles 11y agoYup, you nailed it. cmake for handling the builds, and the C++11 stdlib covers every platform-specific thing I needed. The only platform-specific thing I needed to do was point the CMakeLists.txt at the correct libusb (libusb.so, libusb.dylib, libusb.dll). Absolutely beautiful. Edit: to elaborate a little more about cmake... You can use cmake to generate both Makefiles and Visual Studio build files. On Windows: mkdir build; cd build; cmake .. -G "Visual Studio 12 2013"; cmake --build . On OS X or Linux: mkdir build; cd build; cmake ..; make