Skip to content

Some minor changes were needed for successful build #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GergelyMarton opened this issue Mar 10, 2021 · 1 comment
Open

Some minor changes were needed for successful build #2

GergelyMarton opened this issue Mar 10, 2021 · 1 comment

Comments

@GergelyMarton
Copy link

Hi. Thanks a lot for this tutorial, I guess these might be noob issues, but I just feel like sharing how I could make this code work since it was not evident for me as a non-expert.

  1. Set the Platform Toolset and SDK to fit my config (Visual Studio 2017 (v141) and 10.0.16299.0.)

  2. Built CSharpLibrary, it was successful.

  3. the build attempt of CSharpLibraryBridge gave the following error, which I ignored (since the CSharpLibraryBridge.lib, .dll and other files got created).
    Error MSB3073 The command "powershell.exe -ExecutionPolicy Unrestricted -Command D:\CPlusPlusCLI-Tutorial-master\src\CSharpLibraryBridge\PostBuild.ps1 Release
    :VCEnd" exited with code 1. CSharpLibraryBridge C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 133

  4. In the program.cpp of the NativeCLibrary project, changed the include line for ExampleObj.h:
    //#include <ExampleObj.h>
    #include "../CSharpLibraryBridge/ExampleObj.h"

  5. Created a "lib" folder within the "src" folder and copied the generated "CSharpLibraryBridge.lib" file into it.

  6. After these, the build and execution of NativeCLibrary were also successful.

Thanks again!

@angelru
Copy link

angelru commented Jul 21, 2023

@GergelyMarton I have a C project, could I use this approach to use my dll in C# from the C project? I am very new to C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants