-2

I am attempting to convert the ndn library project found at "https://github.com/named-data/ndn-cpp" into something that can be imported into several existing mfc/wpf/forms Visual Studio Projects (building it as .lib or .dll would work).

As a note, it appears to have previously been converted into c# for windows for a older build of ndn, but is no long supported and will not connect with the current ndn network.(https://github.com/named-data/ndn-dot-net)

I have looked into the using the WSL features that they have added to windows 10, and the Visual studio Linux Cross Platform projects, but these all seem to only be able to make .exes that will run in windows not a .lib or .dll that can be imported into another project.

I have also look into the shared items project but what I was able to find didn't seem like it would work for what I'm trying to do.

Lastly, I tried using cygwin. I was able to compile and generate the linux style libraries(.a) on my windows 10 machine, but when i attempted to generate windows style dlls off the .o files(gcc -shared -o mydll.dll mydll.o) I ran into a large number of reference errors that I was unable to resolve.

Does anyone have any recommendations on which of these methods I should be using or if I should be attempting some other method entirely?

Does anyone have any good references or examples of how to do this for someone with limited Linux experience?

Thanks

marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
user2076574
  • 121
  • 2
  • 11

1 Answers1

0

Ok. I've tried going about this several ways now, and here's what I've learned that might be useful to someone else trying to do this and also where I stand so far:

If you have a simple Linux dll that you have written it's possible to compile it as a Windows dll using MSYS2 or MINGW, instructions are here: http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs

If you have something a bit more complicated like the program I'm trying to convert above, there is no quick fix to convert from Linux to windows, however you still might be able to compile your program for windows using Visual Studio. Here's how you do it:

  1. Download vcpkg from https://github.com/microsoft/vcpkg This is a linux package manager for windows, it will allow you to download windows equivalents to many common Linux packages (for the above I had to download boost and sqlite3)

  2. Create your own unistd.h, here's a link to that: Is there a replacement for unistd.h for Windows (Visual C)?

  3. Get dirent.h for windows, here's a link to that: https://github.com/tronkko/dirent

  4. replace instances of gmtime with _mkgmtime or redefine gmtime as _mkgmtime: timegm cross platform

  5. This got me about 90% of the way there (and from about 13,000 compiler errors to about 30), The rest of the errors so far have been for calls where there is no easy linux to windows conversion and those sections of code have had to be re-written. (In the code above this would be the socket code for the tcp/udp connections in the tranport files, Linux and Windows handle it pretty differently, boost does have a good guide for how to use it's sockets in windows though: https://www.boost.org/doc/libs/1_60_0/more/getting_started/windows.html)

So that's it. Hopefully this helps someone else down the line. I'll be adding more to this answer as I discover new things.

user2076574
  • 121
  • 2
  • 11