-
-
Save giordano/87218e88a5d6943223b306a0443e52a8 to your computer and use it in GitHub Desktop.
Embedding Julia in C++ on CentOS 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM centos:7 | |
RUN yum install -y gcc gcc-c++ make | |
RUN curl -sL "https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.3-linux-x86_64.tar.gz" | tar xzf - -C /usr/local --strip-components=1 | |
COPY embed_example.cpp Makefile /root/ | |
WORKDIR "/root" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <julia.h> | |
#include <string> | |
int main(int argc, char *argv[]) | |
{ | |
std::string teststr = "abc"; | |
/* required: setup the Julia context */ | |
jl_init(); | |
jl_value_t* ans = jl_eval_string("println(sqrt(2.0))"); | |
jl_atexit_hook(0); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JL_SHARE = $(shell julia -E 'joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia")') | |
LIBSTDCXX = $(shell julia -E 'joinpath(dirname(Sys.BINDIR), "lib", "julia", "libstdc++.so.6")') | |
LIBGCC_S = $(shell julia -E 'joinpath(dirname(Sys.BINDIR), "lib", "julia", "libgcc_s.so.1")') | |
CFLAGS += $(shell $(JL_SHARE)/julia-config.jl --cflags) | |
CXXFLAGS += $(shell $(JL_SHARE)/julia-config.jl --cflags) | |
LDFLAGS += $(shell $(JL_SHARE)/julia-config.jl --ldflags) | |
LDLIBS += $(shell $(JL_SHARE)/julia-config.jl --ldlibs) -nodefaultlibs $(LIBSTDCXX) -lc $(LIBGCC_S) | |
all: embed_example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment