Programs linked against shared library behave wrong due to missing compile flag

Bug #1293855 reported by Markus Engel
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
luabind (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

If you compile the attached little program

g++ -o luatest luatest.cpp `pkg-config --cflags --libs lua5.2 luabind`

and run it, you will find the following output:
> ./luatest
function: 0x2529420
function: 0x2525f90

The correct output, though, would be
> ./luatest
42
1337

This only happens when you link against the shared library, with the static library it is working as expected.
This problem may be fixed by adding "-DLUABIND_DYNAMIC_LINK" to the build command when compiling the shared version of libluabind.
I can't get luabind to compile with the Jamfile in the repository, so I can't provide a patch. I made sure this fixes the problem by using a little cmake file though.
The fix is mentioned in the INSTALL file in the windows section only, although config.hpp uses this definition for compiling on linux as well:
#ifdef LUABIND_DYNAMIC_LINK
# if defined(_GNUC_) && _GNUC_ >=4
# define LUABIND_API __attribute__ ((visibility("default")))
# endif
#endif

Revision history for this message
Markus Engel (engelmarkus) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in luabind (Ubuntu):
status: New → Confirmed
Revision history for this message
Markus Engel (engelmarkus) wrote :

Actually, I'm not sure anymore whether the missing flag is the real reason for the problem. It rather seems something went wrong when linking luabind:

> pkg-config --static --cflags --libs luabind
-I/usr/include/lua5.1 -lluabind -llua5.1

> objdump -x /usr/lib/libluabind.so | grep "lua5"
  NEEDED liblua5.2.so.0

Why do the static and shared libraries depend on different versions of lua? This doesn't seem correct.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.