VS2005 failing to export functiions

This is a discussion on VS2005 failing to export functiions within the Windows Programming forums, part of the Platform Specific Boards category; I have this odd problem. Im using RapidMind to speed up some calculations. I wrapped my functions in a DLL, ...

  1. #1
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189

    VS2005 failing to export functiions

    I have this odd problem. Im using RapidMind to speed up some calculations. I wrapped my functions in a DLL, but for some reason the functions are not being exported. The project compiles fine, but when i try to load the library from LabView, the function doesnt show up. I used __declspec(dllexport) in the function declaration.

    example -
    Code:
     
    __declspec(dllexport) void Foo(float* Input , float* Output){
        
        // rapidmind code goes here
     
        return;
        }
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,643
    If it's in a C++ file, then the name will get mangled - in which case you would use this:
    Code:
    extern "C" __declspec(dllexport) 
    void Foo(float* Input , float* Output) {...}
    You may also need to check the calling convention expected by LabView.

    gg

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    Then again, you might want name mangling - otherwise you can't overload and export functions.
    If you're trying to import functions from a C++ project, then name mangling is perfectly fine. If you use C or some other non-trivial method, then you might want to try "extern C" (but you can't export overloaded functions if you do).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    no, the oblem is that the function isnt being exported, mangled or not. Its just not showing up at all. I tried adign teh extern "C" but it made no difference.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    That's the way you do export functions. That or the the function name in a .def file.
    If it doesn't work, then the problem must lie in the application you're using to probe for exported functions.
    And as mentioned, try other calling conventions.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Thats just it, there isnt a problem with LabView, it can access exported functions is all the 9other DLL's, therefor the problem must lie with the DLL itself. And as I said, i alreay tried the other calling conventions. Labview actualyl shows you the list of exported functions, so it woudlnt matter what the callign convention was anyway, it woudl still show up. Its simply not being exported for some reason.
    Last edited by abachler; 12-11-2007 at 01:13 PM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    If you can access the exported functions in the DLL from another application, then the problem DOES lie in LabView. Try it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,643
    Use depends.exe from the PlatformSDK or VisualStudio to inspect the exported symbols from your DLL.

    gg

  9. #9
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    My only guess is you lack this:

    Code:
    #ifdef DLL_EXPORTS
    #define DLL_API __declspec(dllexport)
    #else
    #define DLL_API __declspec(dllimport)
    #endif
    This
    Code:
     
    __declspec(dllexport) void Foo(float* Input , float* Output){
        
        // rapidmind code goes here
     
        return;
        }
    Will always export the function but it will never import it. With what I showed you when you build the DLL you define DLL_EXPORTS in your pre-processor and DLL_API is then export. When you are using the header for the DLL then you do not define DLL_EXPORTS and DLL_API then becomes import.

  10. #10
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Labview doesnt use header files. My guess is it uses the LoadLibrary() functon and accesses the DLL's export table. As it turns out, what was happening is that VS2005 kept using the old OBJ rather than rebuilding, even though changes where made. Obviously the old obj didnt have any functions in it.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  11. #11
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    Erm, OBJ? An obj file is an intermediate compiler file, nothing more. Lib files contain export tables for DLLs and the DLLs contain the actual functions (+ export table).
    Last edited by Elysia; 12-12-2007 at 12:52 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,643
    DLL contains the export table. An "export lib" allows you to dynamically link to a DLL without having to use LoadLibrary() and GetProcAddress() explicitly.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Small code works on VS6 crash on VS2005 WHY???
    By salvadoravi in forum C Programming
    Replies: 7
    Last Post: 02-10-2008, 08:32 AM
  2. run windows exe
    By munna_dude in forum Linux Programming
    Replies: 3
    Last Post: 10-10-2007, 01:12 AM
  3. VS2005 Professional & designated initializers
    By Hansie in forum C Programming
    Replies: 12
    Last Post: 05-25-2007, 12:26 AM
  4. This application failed to start... VS2005
    By Syneris in forum Windows Programming
    Replies: 3
    Last Post: 02-02-2006, 10:47 AM
  5. initializes all components of failing to false
    By romeoz in forum C++ Programming
    Replies: 21
    Last Post: 08-01-2003, 09:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21