CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Oct 2017
    Posts
    5

    [RESOLVED] compile to .dll

    Hello,

    I am a beginner in the coding area, and I started with a very similar language as C+ (called Pawn)..
    There is one issue in the game, which has to be fixed with a code (y axis of the mouse moves faster than the x axis with newer mouses)
    So someone gave me the code to fix this, with a .dll file. But he only gave me the .cpp file and I have no clue how to compile it to a .dll file.

    The code when I open it with the editor is:

    https://pastebin.com/aXUv9VrC

    It would be very kind if someone could just quickly compile this to a .dll file and upload it somewhere, that I can download it :/
    Regards

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: compile to .dll

    someone could just quickly compile this to a .dll file and upload it somewhere
    That's not really the purpose of these forums which is to provide advice and guidance.

    Which os and c++ compiler are you using? We could provide advice as to how you could compile this program.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Oct 2017
    Posts
    5

    Re: compile to .dll

    okay then help me to compile it STEP for STEP..
    I am using Visual Studio Express 2017 with Windows 10 64bit (but I hoped i could compile it that you can use this with all windows versions, since it is possible with many other .dll files created by others)

    What I would basically do to make it run in the game at the end is renaming the .dll to .asi and the .asi-loader is already installed..so I only need the code I sent in the first post to be a .dll and I have NO CLUE at all how to do it

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: compile to .dll

    The .dll created is either for 64 bit or 32 bit. Which version is required depends upon whether the .exe using it (not the os) is 32 or 64 bit.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    Join Date
    Oct 2017
    Posts
    5

    Re: compile to .dll

    hmm let's just call it 'mousefix.dll' and the .exe (which is a game) works for 32 and 64bit..and yes there is already a program installed which would load the .dll

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: compile to .dll

    As the game may work for 32 bit and 64 bit I'm assuming its a 32 bit program.

    In VS,
    File/New/Project/Visual c++/General/Empty Project. At the bottom, change the name and location to that required. Then OK.

    Within Solution Explorer (if not showing View/Solution Explorer), right click source files. Add/New Item/C++ File and provide a suitable name. Then Add. In the main code window (which should have tab saying <name>.cpp), paste the required c++ code. Then File/Save All.

    Once you get to this, post a message and I'll then give how to compile to a .dll
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #7
    Join Date
    Oct 2017
    Posts
    5

    Re: compile to .dll

    done

  8. #8
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: compile to .dll

    Ok. Build/Configuration Manager. Change Active Solution Configuration to Release and check that Active Solution Platform is x86.

    Project/<last option> (which should be xxxProperties).

    Configuration Properties/General Set Output directory as required (ends with a \). Target Extension .dll. Configuration Type Dynamic Library Character Set Use MultiByte

    c/c++/General/Debug Information Format None
    Precompiled Headers Not using precompiled headers

    OK.

    To compile and produce the .dll, Build/Build Solution. You should see in the output window 1 succeeded and you should also see the name of the generated .dll file. Assuming this, then the .dll file has been created OK.
    Last edited by 2kaud; October 24th, 2017 at 08:13 AM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  9. #9
    Join Date
    Oct 2017
    Posts
    5

    Re: compile to .dll

    woooow thank you so much I tested it and it really is working the way it is supposed to be

    I tried watching many tutorials, but nobody explained it that detailed (and everyone had another version)
    but this was perfect feel free to rename the topic, that it could maybe help others with the problem..

    Thank you very very much

  10. #10
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: [RESOLVED] compile to .dll

    You're welcome.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  11. #11
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: [RESOLVED] compile to .dll

    @mikado:

    Next time you find yourself in the situation like this just don't mess with Visual Studio project.
    • Put your .cpp file say to C:\Temp\1\mydllcode.cpp (same to .h files if any)
    • Run Visual Studio Command Prompt of the required bitness (or whatever your VS provides)
    • Change directory to C:\Temp\1
    • ...and finally run the command below

    Code:
    cl.exe mydllcode.cpp /MD /link /dll /out:mydll.dll
    In case the dll make use of C++ STL the command line is modified a bit:
    Code:
    cl.exe mydllcode.cpp /MD /EHsc /link /dll /out:mydll.dll
    In case the dll is to contain some resources, the command lines are:
    Code:
    rc.exe mydllres.rc
    cl.exe mydllcode.cpp /MD /link /dll /out:mydll.dll mydllres.res
    In case you are to debug the dll:
    Code:
    cl.exe mydllcode.cpp /MDd /Zi /link /dll /out:mydll.dll

    That's it. This looks kinda old school, but it will definitely save you some time. And let you understand what goes under the VS hood.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured