Standalone app: how to embed julia by calling DLL in c/c++

Following instructions from the doc: Libraries · PackageCompiler, I have successfully built julia package to DLL. However, I did not find a way to link the final executable in my Visual Studio C++ project: I got LNK2019 and LNK1120 errors related to unresolved external symbols, because .lib files are missing (bug or feature?). Manually generating .lib by MSVC lib.exe does not work (following Building libraries on Windows generates DLLs, but not the corresponding import libraries · Issue #687 · JuliaLang/PackageCompiler.jl · GitHub).

How do I compile my package to DLL and link in a C++ project? More specifically, how to configure environments in Visual Studio and deploy in Windows platform?

I’m not much of an expert on this but came across following enbedding manual. Perhaps it’s usefull. There’s a piece about linking in it. Embedding Julia · The Julia Language

Thanks for reply :D. Embedding julia in VS is one solution. However, it requires user to install julia environment before running the final app.

I’m trying to find another solution, that is, packaging Julia along with the package in a standalone app. That’s also the reason that I’m using PackageCompiler

@MatthijsCox published a nice post that might assist you: Embedding Julia libraries in C++.

Thanks. However, it does not solve the problem:

I also found a similar question (not solved either):

The Julia library itself is linked against many other libraries, it’s not fully self-contained (this is actually useful sometimes, for example if you don’t want to use llvm.dll).

Are you including the entire folder of files generated by PackageCompiler.create_library() ? That folder should be all that’s needed, except for a few system libraries like libc.dll

Yes, I am. In VS project Linker property settings, I appended %(AdditionalLibraryDirectories) with the bin folder generated by PackageCompiler.create_library, and additional dependencies with libjulia.dll.a.

The problem is that, PackageCompiler does not generate a libMyLib.lib file along with the libMyLib.dll.

I have tried to manually generate the missing libMyLib.dll by calling in PowerShell:

& 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\Hostx86\x86\lib.exe' /DEF:libMyLib.dll /OUT:libMyLib.lib /MACHINE:X86

and the error did not vanish.