JuliaInterop / CxxWrap.jl

Package to make C++ libraries available in Julia
Other
418 stars 67 forks source link

Symbol not found when -fvisibility=hidden flag in g++ is used #86

Open bhalonen opened 6 years ago

bhalonen commented 6 years ago

Symbols are not explicitly exported.

The error looks like.

ERROR: LoadError: could not load symbol "register_julia_modules":
lib/plugins/mssa-driver.so: undefined symbol: register_julia_modules
Stacktrace:
 [1] dlsym(::Ptr{Void}, ::String) at ./libdl.jl:55
 [2] load_modules at /root/.julia/v0.6/CxxWrap/src/CxxWrap.jl:141 [inlined]
 [3] wrap_modules at /root/.julia/v0.6/CxxWrap/src/CxxWrap.jl:359 [inlined] (repeats 2 times)
 [4] macro expansion at ./REPL.jl:97 [inlined]
 [5] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading /mitsuba-mods/juliaCall/call-mitsuba.jl, in expression starting on line 4

Adding __attribute__ ((visibility("default"))) to line 1117 in jlcxx.hpp solves it for my complier, but clang would have to be handled as well.

barche commented 6 years ago

I think the proper place to modify this is here: https://github.com/JuliaInterop/CxxWrap.jl/blob/master/deps/src/jlcxx/include/jlcxx/jlcxx_config.hpp#L11

However, I wonder, what is the importance of supporting compilation with hidden symbols? It seems not very common in the Linux world?

bhalonen commented 6 years ago

@barche I think I tried changing it there. However, at https://github.com/JuliaInterop/CxxWrap.jl/blob/master/deps/src/jlcxx/include/jlcxx/jlcxx.hpp#L1136 the JLCXX_API macro is not referenced.

My project is complied with hidden symbols, which may be the default set of flags. Also, according to https://www.ibm.com/developerworks/aix/library/au-aix-symbol-visibility/index.html security, speed, and mitigating the risk of a symbol collision are also concerns.

I'm no ace C++ developer, and this bit of confusion got me for a couple of days.

barche commented 6 years ago

@SylvainCorlay Do you have an opinion on this? I never encountered projects on linux that required hidden symbols, but it seems harmless enough to add the __attribute__, directive, especially since it seems to be the same for both clang and gcc?