Making C++ DLLs with Visual Studio?

I have some portable C++ code that I need to access from Xojo.

So far, I’m using MinGW on Windows for this. It’s quite a pain to manage because I have to hand-write the script (or makefile) to get all the files and libs (C++ runtime, sqlite, pthreads, zlib) correctly linked or I’ll get the dreaded “The specified module could not be found” msg from Xojo at app launch that doesn’t tell me anything what is wrong in particular (e.g. is an entire dll missing, is a dll missing just some symbol, is something else wrong?) I spent half of yesterday just to figure out why my custom DLL would not load into my Xojo code any more after I added sqlite code to it - of course, a test app made in plain C which uses the same DLL ran just fine!

I wonder if I’d fare better with Visual Studio instead.

Has anyone here made DLLs that use C++ and also use 3rd party DLLs (such as sqlite) and got it working with Xojo? Did it go rather smoothly?

You can find SQLite DLL for Windows here prebuilt:
https://sqlite.org/download.html

I have sqlite.dll prebuilt. That’s not what I was asking about.

use Dependency Walker to figure out which DLL is missing.
Maybe you need to copy MinGW’s c runtime dlls to the same folder.

http://dependencywalker.com

I already tried using that the other day, and it was no help. It did not manage to list the missing libs, even after I added the paths to the libs in the mingw folder. It’s been quite a pain and that’s why I am asking if all this would be easier with Visual Studio. Or if VS causes its own issues because it’s not C++14 compliant or has other things that make it difficult to build DLLs for Xojo.

In fact, does the free version of Visual Studio even let me build DLLs?

Visual Studio 2013 Community Edition (free) creates DLL’s that can be used with Xojo. I am downloading 2017 Visual Studio to check if this free edition can create DLL’s for Xojo.

Hi Thomas,

It looks like Visual Studio 2017 free edition can create DLL’s to be used with Xojo. There is a Minimum Version criteria that only allows DLL’s to be built for Windows 10. I don’t know if the DLL’s will be compatible with Windows 8.1 or earlier.

[quote=355596:@Eugene Dakin]Hi Thomas,

It looks like Visual Studio 2017 free edition can create DLL’s to be used with Xojo. There is a Minimum Version criteria that only allows DLL’s to be built for Windows 10. I don’t know if the DLL’s will be compatible with Windows 8.1 or earlier.[/quote]

You can select any toolset version, in 2017 you want. (though you might need to install more to get same versions as 2015 uses). But it is not a problem to do. I use both 2015 and 2017 (mostly because I have not bothered to update all machines yet). And the Free community version is the same as the Full version only diff is your promising that your company has 5 or less people if you use the free one.

I remember now why I used MinGW before: For iBored, I needed to implement pre-emptive threaded code to make use of all available CPUs (for time-intensive disk compression). I decided to use POSIX pthreads with plain C, in order to make it work on Win, Linux and OSX. That worked quite well with MinGW on Windows - had I used VS for that, I’d have had to use a different thread library because VS does not offer POSIX pthreads. That was all without C++.

Now, with my current project, I need C++, but not pthreads (although I still need to include the DLL with my app, because it’s used by the C++ runtime). And that’s where I ran into a lot of new problems. I’ve figured them out now, but if I run into more, I’ll see if I can move this to VS instead.

Thanks for all the comments!