Skip to content
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

Remarks for Debian #17

Closed
gabrieldevillers opened this issue Jun 11, 2020 · 3 comments · Fixed by #18
Closed

Remarks for Debian #17

gabrieldevillers opened this issue Jun 11, 2020 · 3 comments · Fixed by #18
Labels
bug Something isn't working

Comments

@gabrieldevillers
Copy link

gabrieldevillers commented Jun 11, 2020

Thanks for this project, very useful demo.

I had trouble building the file DNNE/test/ExportingAssembly/obj/Debug/net5.0/dnne/ExportingAssembly.g.c
The error were:

platform.c(222,5): error GCEFF6793: use of undeclared identifier 'Dl_info'
platform.c(223,47): error GCEFF6793: use of undeclared identifier 'info'
[...]

The command was: Building native export: "clang" -g -O0 -shared -fpic -D DNNE_ASSEMBLY_NAME=ExportingAssembly -I "/home/gabriel/.nuget/packages/dnne/1.0.3/tools/platform" -I "/home/gabriel/dev/dotnet-sdk/dotnet-sdk-5.0.100-preview.6.20309.18-linux-x64/packs/Microsoft.NETCore.App.Host.linux-x64/5.0.0-preview.6.20305.6/runtimes/linux-x64/native" -lstdc++ -o "/home/gabriel/dev/DNNE/test/ExportingAssembly/obj/Debug/net5.0/dnne/bin/ExportingAssemblyNE.so" "/home/gabriel/dev/dotnet-sdk/dotnet-sdk-5.0.100-preview.6.20309.18-linux-x64/packs/Microsoft.NETCore.App.Host.linux-x64/5.0.0-preview.6.20305.6/runtimes/linux-x64/native/libnethost.a" "/home/gabriel/dev/DNNE/test/ExportingAssembly/obj/Debug/net5.0/dnne/ExportingAssembly.g.c" "/home/gabriel/.nuget/packages/dnne/1.0.3/tools/platform/platform.c"

The solution I found was to add #define __USE_GNU 1 before #include <dlfcn.h> in platform.c (I modified /home/gabriel/.nuget/packages/dnne/1.0.3/tools/platform/platform.c because I failed to find the good commands to regen/override/bypass the server the current nuget package).

Also I failed to understand what should provide the function get_hostfxr_path in platform.c (link time problem) so I changed:

    // Discover the path to hostfxr.
    char_t buffer[DNNE_MAX_PATH];
    size_t buffer_size = DNNE_ARRAY_SIZE(buffer);
    int rc = get_hostfxr_path(buffer, &buffer_size, NULL);
    if (is_failure(rc))
        noreturn_runtime_load_failure(rc);


    Load hostfxr and get desired exports.
    void* lib = load_library(buffer);

into:

    void* lib = load_library("libhostfxr.so");

and then I added the directory containing libhostfxr.so to LD_LIBRARY_PATH.

@AaronRobinsonMSFT AaronRobinsonMSFT added the bug Something isn't working label Jun 11, 2020
@AaronRobinsonMSFT
Copy link
Owner

@gabrieldevillers Thanks for reporting this issue. I will admit I didn't do a lot of linux validation. I focused on Windows and macOS because that is what I had easily available. I did run a simple sanity check on Ubuntu 16.04 initially but nothing since then.

The solution I found was to add #define __USE_GNU 1 before #include <dlfcn.h> in platform.c

Good to know. I will check that out and see what I am missing in this scenario.

Also I failed to understand what should provide the function get_hostfxr_path in platform.c (link time problem) so I changed:

The link time failure is the issue here. The libnethost.a is the tool that helps find the libhostfxr.so binary, so if linking failed that is the root issue. Your solution is correct, but shouldn't be needed if libnethost.a is properly linked in.

Based on the command line the following library should be included: "/home/gabriel/dev/dotnet-sdk/dotnet-sdk-5.0.100-preview.6.20309.18-linux-x64/packs/Microsoft.NETCore.App.Host.linux-x64/5.0.0-preview.6.20305.6/runtimes/linux-x64/native/libnethost.a". Can you help me out and verify this file exists? If so making that link properly as a static lib should solve the second issue.

@AaronRobinsonMSFT
Copy link
Owner

The solution I found was to add #define __USE_GNU 1 before #include <dlfcn.h> in platform.c

Good to know. I will check that out and see what I am missing in this scenario.

@gabrieldevillers Boo. This was my issue. I don't recall how I validated this on Linux. It is properly documented here and here. I will see about validating this using #define _GNU_SOURCE.

@gabrieldevillers
Copy link
Author

Based on the command line the following library should be included: "/home/gabriel/dev/dotnet-sdk/dotnet-sdk-5.0.100-preview.6.20309.18-linux-x64/packs/Microsoft.NETCore.App.Host.linux-x64/5.0.0-preview.6.20305.6/runtimes/linux-x64/native/libnethost.a". Can you help me out and verify this file exists? If so making that link properly as a static lib should solve the second issue.

find -iname "*libnethost*" in dotnet-sdk-5.0.100-preview.6.20309.18-linux-x64 gives:

./shared/Microsoft.NETCore.App/5.0.0-preview.6.20305.6/libnethost.a
./packs/Microsoft.NETCore.App.Host.linux-x64/5.0.0-preview.6.20305.6/runtimes/linux-x64/native/libnethost.a
./packs/Microsoft.NETCore.App.Host.linux-x64/5.0.0-preview.6.20305.6/runtimes/linux-x64/native/libnethost.so

I misremembered, I do not get a link time failure but a runtime failure:

Loading library: ../ExportingAssembly/bin/Debug/net5.0/ExportingAssemblyNE.so
mod is: 0x5585ad23a6f0
./ImportingProcess: symbol lookup error: ../ExportingAssembly/bin/Debug/net5.0/ExportingAssemblyNE.so: undefined symbol: get_hostfxr_path

Also I forgot to tell you that I also had to add this to ImportingProcess/CMakeLists.txt:

target_link_libraries(ImportingProcess dl pthread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants