{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/18192","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/18192/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/18192/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/18192/events","html_url":"https://github.com/JuliaLang/julia/issues/18192","id":172578102,"number":18192,"title":"julia-0.5: Undefined reference to jl_tls_states when embedding julia","user":{"login":"ronisbr","id":1068295,"avatar_url":"https://avatars.githubusercontent.com/u/1068295?v=3","gravatar_id":"","url":"https://api.github.com/users/ronisbr","html_url":"https://github.com/ronisbr","followers_url":"https://api.github.com/users/ronisbr/followers","following_url":"https://api.github.com/users/ronisbr/following{/other_user}","gists_url":"https://api.github.com/users/ronisbr/gists{/gist_id}","starred_url":"https://api.github.com/users/ronisbr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronisbr/subscriptions","organizations_url":"https://api.github.com/users/ronisbr/orgs","repos_url":"https://api.github.com/users/ronisbr/repos","events_url":"https://api.github.com/users/ronisbr/events{/privacy}","received_events_url":"https://api.github.com/users/ronisbr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/embedding","name":"embedding","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-22T23:24:02Z","updated_at":"2016-08-22T23:30:02Z","closed_at":null,"body":"Hi guys!\r\n\r\nI'm trying to compile this simple C++ program with julia embedded:\r\n\r\n```C++\r\n#include <iostream>\r\n#include <julia.h>\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n    jl_init_with_image(const_cast<char*>(\"/usr/lib64/julia\"),\r\n                       const_cast<char*>(\"./sys.so\"));\r\n\r\n\r\n    jl_function_t *func = jl_get_function(jl_base_module, \"sqrt\");\r\n    jl_value_t *argument = jl_box_float64(2.0);\r\n    jl_value_t *ret = jl_call1(func, argument);\r\n    JL_GC_PUSH1(&ret);\r\n\r\n    std::cout << jl_unbox_float64(ret);\r\n\r\n    JL_GC_POP();\r\n    jl_atexit_hook(0);\r\n    return 0;\r\n}\r\n```\r\n\r\nWhen I try to compile using\r\n\r\n```\r\ng++ -fPIC julia.cpp -I/usr/include/julia -ljulia\r\n```\r\n\r\nI'm getting the error:\r\n\r\n```\r\n/tmp/cc3oFlKL.o: In function `main':\r\njulia.cpp:(.text+0xc2): undefined reference to `jl_tls_states'\r\njulia.cpp:(.text+0xd8): undefined reference to `jl_tls_states'\r\njulia.cpp:(.text+0x101): undefined reference to `jl_tls_states'\r\njulia.cpp:(.text+0x10f): undefined reference to `jl_tls_states'\r\ncollect2: error: ld returned 1 exit status\r\n```\r\n\r\nI saw that the error is related with the functions `JL_GC_PUSH1` and `JL_GC_POP`. My julia version was compiled using:\r\n\r\n```\r\nUSE_SYSTEM_LLVM=0 \\\r\nUSE_SYSTEM_LIBUNWIND=1 \\\r\nUSE_SYSTEM_READLINE=1 \\\r\nUSE_SYSTEM_PCRE=1 \\\r\nUSE_SYSTEM_LIBM=0 \\\r\nUSE_SYSTEM_OPENLIBM=1 \\\r\nUSE_SYSTEM_OPENSPECFUN=1 \\\r\nUSE_SYSTEM_DSFMT=1 \\\r\nUSE_SYSTEM_BLAS=1 \\\r\nLIBBLASNAME=libblas.so.3 \\\r\nUSE_SYSTEM_LAPACK=1 \\\r\nLIBBLASNAME=liblapack.so.3 \\\r\nUSE_SYSTEM_FFTW=1 \\\r\nLIBFFTWNAME=libfftw3_threads.so.3 \\\r\nLIBFFTWFNAME=libfftw3f_threads.so.3 \\\r\nUSE_SYSTEM_GMP=1 \\\r\nUSE_SYSTEM_MPFR=1 \\\r\nUSE_SYSTEM_ARPACK=1 \\\r\nUSE_SYSTEM_SUITESPARSE=1 \\\r\nUSE_SYSTEM_ZLIB=1 \\\r\nUSE_SYSTEM_GRISU=1 \\\r\nUSE_SYSTEM_RMATH=0 \\\r\nUSE_SYSTEM_LIBUV=0 \\\r\nUSE_SYSTEM_UTF8PROC=0 \\\r\nUSE_SYSTEM_PATCHELF=1 \\\r\nUSE_SYSTEM_LIBGIT2=1 \\\r\nUSE_SYSTEM_MBEDTLS=1 \\\r\nUSE_SYSTEM_LIBSSH2=1 \\\r\nUSE_MKL=0 \\\r\nUSE_BLAS64=0 \\\r\nUSE_LLVM_SHLIB=0 \\\r\nVERBOSE=1 \\\r\nUSECLANG=0\r\n```\r\n\r\nI used `objdump` and saw that the symbol `jl_tls_states`  **is not** present in `libjulia.so.0.5.0`."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/241582573","html_url":"https://github.com/JuliaLang/julia/issues/18192#issuecomment-241582573","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/18192","id":241582573,"user":{"login":"tkelman","id":5934628,"avatar_url":"https://avatars.githubusercontent.com/u/5934628?v=3","gravatar_id":"","url":"https://api.github.com/users/tkelman","html_url":"https://github.com/tkelman","followers_url":"https://api.github.com/users/tkelman/followers","following_url":"https://api.github.com/users/tkelman/following{/other_user}","gists_url":"https://api.github.com/users/tkelman/gists{/gist_id}","starred_url":"https://api.github.com/users/tkelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkelman/subscriptions","organizations_url":"https://api.github.com/users/tkelman/orgs","repos_url":"https://api.github.com/users/tkelman/repos","events_url":"https://api.github.com/users/tkelman/events{/privacy}","received_events_url":"https://api.github.com/users/tkelman/received_events","type":"User","site_admin":false},"created_at":"2016-08-22T23:30:02Z","updated_at":"2016-08-22T23:30:02Z","body":"https://github.com/JuliaLang/julia/pull/17745#issuecomment-236736554 you're missing a threading flag (and so are the embedding docs)"}}
{"actor":{"display_login":"tkelman"}}