I use code::blocks as an IDE but now i want to create a .dll file. I have followed this tutorial however it is for VC++.

TUTORIAL:
http://msdn.microsoft.com/en-US/library/vstudio/ms235636

I am strugeling becuase I am used to creating .dlls in C#. They are so easy. You just create a new library project. Write your code eg:

    // The .dll version
    using System;
    namespace SomeName
    {
        class Class1
        {
            public int add(int x, int y)
            {
                return x + y;
            }
        }
    }

    // The real "runable" version
    using System;
    namespace AgainSomeName
    {
        class Class2
        {
            public void Main(string[] args)
            {
                SomeName.Class1.add(5, 3);
            }
        }
    }

Thats it. All you have to do now is right click on your project in your IDE and then say add reference and add the .dll file. Easy usable. Isnt there a way to do it like as easy as that. Without having to use all those #ifdef, #endif, #else and static __declspec(dllexport) words. Easy like you do it in C#?

Oh and also, if i use Visual studio C++ exspress can i then only create programs for the .NET when i use that IDE? or whill the programs work for computers without the .NET alsong as i just dont include .NET header files?

As I'm sure you noticed when you read the documentation, creating libraries in C++ is very different to C# (in my opinion most things tend to be more difficult in C++). I imagine the complexity in C++ is essentially down to the close-knit relationship between C++ and C (I'm just guessing though). Anyway, its important to realise why __declspec(dllexport) is actually necessary: basically its used to expose a function with C++ name mangling. So, if this is not what you want then perhaps you should consider using extern "C" which tells the compiler not to apply the usual C++ decorations in the symbol table.

Unfortunately, I have never attempted to create a C++ dll in Code::Blocks, however, after a quick search using Google I found this which may be of some use to you (apologies in advance if its not).

Good Luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.