Skip to content

Embedding Julia in C on Windows #28969

@NiklasGustafsson

Description

@NiklasGustafsson

Following the article on how to embed Julia in C/C++ programs, using Windows, surfaces two problems:

  1. The article doesn't really cover using Windows / Visual Studio at all. Since it does work on Windows, I think it would be valuable to add those instructions, too.

  2. A few of the symbols exported from libjulia.dll have "__threading" appended to their names. I found that I needed to modify my local copy of julia.h to get the program to link and run:

#ifndef _OS_WINDOWS_
JL_DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel);
JL_DLLEXPORT void jl_init(void);
JL_DLLEXPORT void jl_init_with_image(const char *julia_bindir,
                                     const char *image_relative_path);
#else
JL_DLLEXPORT void julia_init__threading(JL_IMAGE_SEARCH rel);
JL_DLLEXPORT void jl_init__threading(void);
JL_DLLEXPORT void jl_init_with_image__threading(const char *julia_bindir,
	                                            const char *image_relative_path);
#define julia_init julia_init__threading
#define jl_init jl_init__threading
#define jl_init_with_image jl_init_with_image__threading
#endif

For jl_init(), specifically, there is also an exported symbol 'jl_init_threading' (just one underscore before 'threading').

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions