Free C++ Compilers and KX DSP

Discussion in 'Effects and the DSP' started by ROBSCIX, Sep 16, 2005.

  1. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    But I did D/L the SDK and its .net - but was for Server 2003 - ?? Its so damn confusing...
     
  2. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    The 'About' window should tell you exactly what verison it is. You keep saying C, but I assume you mean C++ (I do not think there is a VC? as opposed to VC++). In any case, the reason I asked is because I also have that version (although mine in not NFR). I am surprised it did not come with the MSDN help (I suppose it is possible (i.e the downgrade version of VC++ 6 did not include the older help), but, are you sure your friend gave you all the CD's?), but all that info is available free online anyway, at the MSDN site (it is just easier if it is installed locally). The MSDN subscription thing is different, it is not really about the help.

    And yes, the SDK names are somewhat confusing, but that should be the right version.
     
    Last edited: Dec 20, 2005
  3. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Yes it Is 'Microsoft Visual C++ 2003 .NET' - and there must a disc missing - but he swears he never dont have it. Even tho there wasnt anything indicating a missing disc - just 1 disk and it installed - THEN finished and asked if I would like to install the MSDN help - I couldnt as I dont have the disc- but it still seems to run.. ??

    - I looked (quite a bit too) at M$ and all I run into is buying a MSDN subscription for access or have archives sent on cd - Thats all Ive found anyway. No CHM or HLP files to D/L - Im not even sure what I would order if I even cared to do so. So Im thinking it is a 'student version'.
     
  4. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Mine came with like 7 CD's... Of course I do not remember what is on each CD. I think one is a system check type of disk which is used to update components, another is the VC++ installation (actually 2 disks, but one might just be extras, I do not remember). 3 are the MSDN library, and one is the latest service pack (at the time). It is possble that the NFR versions are like what you have.

    One thing to note about the Help/MSDN library, it is not a tutorial, or the type of help you might be thinking it is. It is more of a language reference, ie. documentation of functions, etc. The same exact help is available online (for viewing online, i.e. not to download .CHM files, etc).

    Look here (use Internet Explorer (and sync the toc), Firefox messes it up some times):
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcedit/html/vcorivisualcmainnode.asp

    <edit>
    fixed above link to point to VC++ docs
     
    Last edited: Dec 20, 2005
  5. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Ahhh - it was FF I used and not seen the TOC there.

    Yes - I understood the help was reference and not tutorial -

    Thanks again...

    I bet my friend threw them discs away not knowing what they were... the lunk-head
     
  6. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    @Max;
    Did you actualy managed to staticly link kxapi.dll
    (or any other MSVC DLL that exports classes by __declspec(dllexport)
    without extern "C" for that matter) in lets say, mingw/Dev-C++?

    For anyone else interested in this kinda stuff, here's what I did as a test case;

    1. Write and build a WIN32 Test.dll in MSVC;
    Code:
     
    /////////////////////////////////////////////////////////////////////////////////
    // mydll.h -DLL declaration 
    ////////////////////////////////////////////////////////////////////////////////
    #include <windows.h>
    #ifdef LEMURY_EXPORTS
    #define LEMURY_API __declspec(dllexport)
    #else
    #define LEMURY_API __declspec(dllimport)
    #endif
     
    class LEMURY_API CMyClass
    {
    public:
    CMyClass();
    ~CMyClass(); 
    int my_function(int value); 
    };
     
    /////////////////////////////////////////////////////////////////////////////////
    // mydll.cpp -DLL implementation
    ////////////////////////////////////////////////////////////////////////////////
    #define LEMURY_EXPORTS
    #include "mydll.h"
    // Had an entry point here, but doesn't make any diff.
    CMyClass::CMyClass()
    {
    OutputDebugStringA(" Construct Yeah!");
    };
    CMyClass::~CMyClass()
    {
    OutputDebugStringA("Destruct Whoo!!");
    };
    int CMyClass::my_function(int value)
    {
    OutputDebugStringA("Function, duhh..!");
    return value;
    };
    Now here's the problem;
    We have MSVC Test.DLL and Test.LIB, but unfortunatly we can not simply link Test.LIB with MinGW (or any other compiler) because it is in Microsoft format and contains name mangled funtion names.
    All tricks to get around this issue I've seen do basicly the same:

    -Extract a .DEF export list from the third-party DLL or .LIB,
    -edit it,
    -build a new import library file from the edited .DEF file.

    Here it goes;
    2. produce a Test.DEF file from the Test.dll;
    IMPDEF Test.def Test.dll
    or,
    PEXPORTS -o -h Test.h Test.dll>test.def
    or,
    DUMPBIN etc, etc,...

    Output looks like this:
    LIBRARY Test.dll
    EXPORTS
    ??0CMyClass@@QAE@XZ @1
    ??1CMyClass@@QAE@XZ @2
    ??4CMyClass@@QAEAAV0@ABV0@@Z @3
    ?my_function@CMyClass@@QAEHH@Z @4

    3. Edit the exports function names in the .DEF file by giving them aliases like;
    _imp__myfunction = ?my_function@CMyClass@@QAEHH@Z @4
    etc.

    4. build the .a library file from the above .DEF file;
    DLLTOOL -U -d Test.def -l libTest.a

    Now link libTest.a as the import library for a simple testApp.exe in MinGW/Dev-C++;
    Code:
     
    ///////////////////////////////////////////////////////////////////////
    // DEV-C++ Test App that uses class from MSVC dll
    ///////////////////////////////////////////////////////////////////////
    #include "mydll.h" // The above .dll header
    #include <stdio.h>
    //-----------------------------------------------------------------
    int main()
    {
    CMyClass* p;
    p = new CMyClass;
    if(p)
    {
    printf("....p ok!\n");
    p->my_function(2);
    }
    else printf("....p Error!\n");
    printf("Press a Key to quit:..\n\n");
    getchar();
    if(p){delete p; p=0;}
    return 0;
    };
    Well, I've tried all kinds of settings/tricks/tools/switches, but it still doesn't work.
    It will link but the app can't find the Class function entry points.

    Well we could always do dynamicly LoadLibrary() approach
    which will bypass all this crap, but rather not.

    Any thoughts anyone, or care to share some info Max?

    BTW: I'm curious how many people realy are interested in using a free compiler for
    writing their kX plugins?

    /LeMury
     
    Last edited: Dec 28, 2005
  7. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    Forgot,

    I've also tried Borland C++Builder applying all the Borland tips&tools regarding third party DLL usage.
    Also no luck!

    /LeMury
     
    Last edited: Dec 28, 2005
  8. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    For me...
    I would like to learn C++, but as I wrote above - its difficult to find 'interesting' examples that are well documented. Being a music type-o-guy - playing with C++ with KX is the 'interesting' aspect I desire - and code I looked at in KX API looks simple enough for me to figure out with out extensive commenting/docs. (THEN theres the DANE tho too.. :S)

    Im still getting a grip on how the sound cards architecture is - which Im certain is necessary to program much of anything for it. So Im a ways off from anything really productive.

    Now - I have to beleive that if theres a way to compile with freeware - would open the doors for some other 'non-pros' to dive in and maybe skin up some un-skinned plugins, if not develop new ones.

    If I understand correctly - what your proposing is that - fucntion calls can be identified by making (some utility exists to do this I presume) a creating a new .DEF - I imagine the tool used does some sort of reverse engineering of a DLL when you dont have access to the source.

    THEN aliases are assigned that are 'freeware compiler' friendly - thus (theoretically) possible to compile with a compliler compatable with these new aliases -
    I imagine 1 alias file would be for MingW - and one for DevC++.

    Am I following this correctly?

    Does the KXAPI.DLL contain code thats protected by an NDS?

    I guess I assumed CL provided a DLL directly as well as info on what functions are performed by that DLL, rather than supply source code.

    Sorry Im not answering questions for you - but Im (maybe a little too much) the curious type and would like to understand these things better.

    Im trying to decide which direction to go - M$VC++ and make some things easier...
    Or use Open source and have more flexibility (like future proofing) but more complicated.

    I would glady dump M$VC++2003.NET - as I only installed it thinking it would be easier to learn with. But - between limited KX API compatability, AND with M$VC++ docs 'ONLINE only' in my case makes it a bit more tedious and slow.

    I also read complaints about .NET in some articles Ive been reading - but I do account for the 'old dogs and new tricks' potential motivation behind such comments.
    I didnt uderstand the complaints, just sounds negitive enough to question and evaluate any alternatives.

    Can other apps be developed also this way - not just plugins??
     
  9. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Do not confuse the .NET comments that you see, with VC++ .NET. I think the negative comments you see, are most likely related to managed C++. VC++ 2003 .NET allows you to do both managed C++ and regular C++.

    As far as the DEF file goes, different compilers decorate (name mangling) the function names a different way. The name decoration is just the way the compiler see's it itself. The DEF file just makes a name alias (not reverse engineering or anything). Also for regular .dll functions, etc, it is easy enough to make it not decorate the names. It is .dll claases and class functions that LeMury is talking about, and this is mainly an issue with linking to libs in one compiler, that were created by another compiler. (i.e. using a free compiler to link with kxapi.lib). BTW: MingW is the compiler, Dev C++ is just the IDE (i.e. a graphical front end).

    Regarding opensource, that really has nothing to do with the compiler. It is not a VC++ vs free compiler topic. You can do opensource things in any compiler.
     
  10. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Ok - I see I have WAY more reading up on the subject - so Ill shut up now.... :S

    Thanks for the info...

    But... just so Im clear - If I take (any win32) source code (assuming I have all libs linked to in the code - and code was meant for my OS), M$VC++2003.NET can compile without any code changes?

    I Assumed (or thought I read) potentially significant changes to the code would need to be made to successfully compile.
     
  11. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Yes, for any pure Win32 (C++) code you should be able to do that. It would be only a matter of setting up the environment correctly (correct compiler and linker options, etc).
     
  12. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Ahh - ok good to know...

    Is it just me - or did everyones brain explode :-s
     
  13. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    @LeMury,
    I did mange to get it to work using wrapper functions to access the class instead of trying to access the class directly. Of course that is not going to help with the kxapi. (BTW: I was able to use the lib directly instead of creating the libTest.a)
     
    Last edited: Dec 22, 2005
  14. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    Hmm,...yes, well I managed to resolve the linker errors both with mingw as well as C++Builder
    and got it to compile, but the app just can't find the correct entry points in the dll.

    Which compiler did you use btw? (i dont mean your MSVC variant)
     
  15. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    I used MingW with Dev C++ (which BTW, seems to be unstable at times).
     
  16. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    I managed to get rid of the linker errors as well (when trying to access the class directly), but I am not sure that what I tried was valid (I posted info about it previously, but then deleted it...). When I looked at some of the files in Dependancy walker, I could see that the entry points were not valid, so I figured it was just fooling the compiler, but not really doing what it was supposed to do.
     
  17. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    Yes, I'm afraid that this is not going to work.
    (I mean staticly linking exported C++ classes from another compiler)
    Only way I know that works for sure is manualy loading, or a helper dll inbetween.

    Hmm,.. minGW works stable for me.
    I recently (re-)compiled quite some VSTis (which I originaly wrote with MSVC) with mingw,
    and I must say it's performance doesn't differ much from VC6.
    Only .NET optimizing compiler gave (slightly) better performance.
    Not bad for a free compiler I'd say.

    [EDIT]
    I deviate;
    The goal of this all was/is to provide a way, for people who can't afford to buy MSVC,
    to use kX SDK writing some stuff.
    Basic dialogs and controls are easily written using win32 api or use some free GUI framework. Most people want to 'skin' anyway in which MFC doesn't help a bit imo.

    Something in the spirit of; Free driver, free SDK, free plugins,....free compiler???
     
    Last edited: Dec 28, 2005
  18. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Regarding the stability, it could just be the version I am using (Dev-C++ 5.0 beta 9.2 (4.9.9.2) with Mingw/GCC 3.4.2). When I was changing some of the project options (i.e. removing a lib) it would give an error about an access violation (after I click OK), and then (if I choose to continue) would act up on me. Otherwise it was OK. I haven't used it very much, so maybe something just got corrupted, and this type of thing is not common.
     
  19. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    Ah yes, Dev-C++ IDE is bit unstable.
    But nonetheless still one of the best free ones imo.
     
  20. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    BTW: I do not think this should be an issue with one of the free MS compilers. It might be worth trying with Visual C++ 2005 Express, while it is still available for free. It looks like it will co-exist without problems with other Visual Studio products, so maybe if I have the chance I will take a look. If anyone else tries, post your results.
     

Share This Page

visited