Blitz3D and C++ DLL coding question

Blitz3D Forums/Blitz3D Programming/Blitz3D and C++ DLL coding question

videz(Posted 2014) [#1]
I'm new to DLL programming so I'm not sure what compiler to use. Currently I have CodeBlocks Setup with either VC2008/2010 or MinGW and I'm trying to test a simple DLL here

http://www.blitzbasic.com/Community/posts.php?topic=51944

It mentions coding in Dev C++. Can I use VC2010 or CodeBlocks instead? I'm currently using V1.106


videz(Posted 2014) [#2]
...Ending up installing and trying it out in Dev C++ and it works. Maybe there's a solution for VC2010 or CodeBlocks???


Rroff(Posted 2014) [#3]
I ended up going back to using LCC compiler for blitz userlib dlls :S not sure what the problem is but I'm assuming new stuff like VC 2013 is building dlls that can't be loaded with plain loadlibrary or something though I did try messing with the character set.


videz(Posted 2014) [#4]
Thanks Rroff for this info. I didn't know about LCC, does this particular compiler support latest C frameworks?


Yasha(Posted 2014) [#5]
Blitz3D DLLs are simple once you get the hang of them. All you need is a compiler that lets you build DLLs and supports the stdcall calling convention.

You don't need a fancy environment like an IDE, and if this is your introduction to C or C++ programming, you should definitely avoid them as they make life much, much more complicated. You should also avoid Visual Studio unless you actually need it as it's different and strange and doesn't do things the normal way. (And you should avoid Dev-CPP because it's ridiculously outdated.)

MinGW works best; if that's too big an install for the moment you might also consider TCC, which is C-only, but very small (less than 1MB!).

A DLL is just a library that has been compiled with the -shared flag. You can just write up your C library (it has to be a C library: if you're using C++ you will need wrapper functions) in a text editor like Notepad++ and then build on the command line. This will give you a much deeper understanding of the process than the huge tools that obscure what they're actually doing, and is more than efficient enough for most real work. (in fact it's likely to be a lot faster and simpler for shorter tasks like B3D wrapping)


Rroff(Posted 2014) [#6]
^^ For some reason I've not been able to build dlls with any recent version of Visual Studio that will work with b3d - not really troubled myself too much about why as I can just build them on an older C compiler.

EDIT: Also one of the working compilers produces almost byte for byte identicall dlls to VS so must be some encoding issue or something fairly small thats putting it off.


videz(Posted 2014) [#7]
Thank you for this huge amount of info Yasha. Now I understand that B3D uses C with DLLs. I thought you can use both C/C++ easily.

I don't mind using old compilers as long as it can compile recent frameworks done in C/C++. Because most of the time you can't reinvent the wheel and need to use existing frameworks and technologies, and most of these libraries/packages are built towards the recent VS products or MinGW with CMake or Make.

I would also prefer MinGW and now that I already tested that it (Orwell Dev C++) works with Blitz, it's a sigh of relief :-)

Question: If I use Ploppy's VS2010 Blitz3D built, can I still create a DLL made with other or old compilers and hook them on that build version?

@Rroff
Yes, same here. I dont have any luck with VS past VC6. But it's good to know that recent MinGW version works fine :-)