DLL file question

This is a discussion on DLL file question within the C Programming forums, part of the General Programming Boards category; thanks, I'll try that out...

  1. #16
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    ok

    thanks, I'll try that out

  2. #17
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    more info...

    ok, here's some more info: listed above the error messages is this:

    C:\dmc\dm\bin\..\lib\SNN.lib(thsup)
    Error 42: Symbol Undefined _GetCurrentThreadId@0
    C:\dmc\dm\bin\..\lib\SNN.lib(semlock)
    Error 42: Symbol Undefined _CreateSemaphoreA@16
    C:\dmc\dm\bin\..\lib\SNN.lib(semlock)
    Error 42: Symbol Undefined _ReleaseSemaphore@12

    and the list goes on. still the same advice?

  3. #18
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Yes. Those 3 functions are all defined in kernel32.dll.

  4. #19
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    i cant remember

    usually, I don't have problems with crap like this, but i cant remember where kernel32.dll is.

  5. #20
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    nevermind

    I found it!

  6. #21
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    wrong solution?

    I'm not sure if i made this clear enough. I'm not trying to write a program using code from a DLL, I'm trying to write my own DLL for a BASIC App. that I'm working on. I want to write it, because im hoping that a C function will be faster than a BASIC function. any advice?

  7. #22
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    On how to write your own DLL?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #23
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    umm...

    yes. absolutely. thats what ive been trying to do this whole time... any clue what I'm supposed to do?

  9. #24
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    This depends on your compiler. I've never used the digitalmars compiler before, so I can't help you. I suggest reading your compiler's documentation and help files.

    Typically, you need to tell your compiler which functions are being exported. This is done with a .DEF file, or a keyword in the exported function's signature (like __declspec(dllexport) on MSVC compilers). Lastly, there is some directive that you give to the linker which tells it you are creating a DLL file instead of a normal executable.

  10. #25
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    ok

    yeah, i knew that I had to use the commandline switch -WD, but as for the definitions file, do I link to the def file or what?

  11. #26
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    yes, you do.

  12. #27
    Registered User
    Join Date
    Mar 2006
    Posts
    150
    do i link the a library to the .def file, or do I link the program to the .def file? Can you maybe give me an example program and def file, so that i can see what i need to do?

  13. #28
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    That question doesn't really make sense. You pass the DEF file to the linker during the linking stage. On MSVC this is done by "/def myfile.def".

    Here is an example of a .DEF file:
    Code:
    ; myfile.def : exported library symbols
    
    LIBRARY      "mylib"
    DESCRIPTION  'mylib Windows Dynamic Link Library'
    
    EXPORTS
         foo
         bar
    And your code:
    Code:
    int __stdcall foo(void)
    {
       return 1;
    }
    
    void __stdcall bar(int a)
    {
       a++;
    }

  14. #29
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    ok

    well, my compiler preprocesses, links, and compiles all on its own. do i need to link the def file to my program, or to a library file, such as the above kernel32.lib?

  15. #30
    Registered User
    Join Date
    Mar 2006
    Posts
    150

    also...

    do i need to declare a main() function in the program? the DLL compiles right when i do, but i dont understand how i would call the function in the DLL file... this is alot more complicated than it needs to be....

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. A question about file streams.
    By Lawn Gnomusrex in forum C++ Programming
    Replies: 2
    Last Post: 11-07-2008, 06:05 AM
  3. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-22-2008, 12:19 AM
  4. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  5. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM

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