Goal: use a 3rd party library in my c++ project, on Windows and Linux.

Continuing from post 4a, where I configured the Linux build.

 

I'm assuming here that the 3rd party provides a compiled lib and the necessary header files. And that you did the steps in that post.

 

Link and Test on Windows x86 / x64

In my use case, the 3rd party library archive for windows contains a .dll and .def file.

That's good. We can work with that. We can even work with a plain .dll only. But when the .def file is available too, we have better debug support.

The GCC linker needs a more common (read linux-ish) library than the .dll to build an executable.

But all the tools to build that library are available in the GCC toolchain.

We just have to execute this command (part of the cygwin/mingw distro):

 

dlltool --def uFCoder-x86_64.def --dllname uFCoder-x86_64.dll --output-lib uFCoder-x86_64.a

 

You can choose to do that one time, or as a pre-step in the Eclipse build process for Linux.

If you take the second option, the file will be re-generated often. But you don't have to remember the command line when you switch to a new version of the 3rd party lib. Your choice.

 

Now that I have all artifacts, it's time to set up the windows configs:

Again it's  a good point to learn how to configure a set of configurations in a single action.

I only want to define settings for the Windows toolchain. In stead of selecting All configurations, I'll check Multiple configurations.

First the include file.

Then the library.

 

That should do for the build part:

Then execute the Windows Debug configuration from previous post (don't forget to move the smart card reader from the Linux USB to one of your Windows computer USB ports).

The window executable depends on the 3rd party dll. So we have to add it to the build path:

This works, exactly like on Linux. That was the goal.

 

Finish.

 

related blog
Part 1: preview
Part 2: start multi-target project
Part 3: debug on both platforms
Part 4a: link 3rd party library on Linux ARM
Part 4b: link 3rd party library on Windows