CMake + Lua + IUP: dynamic libraries not enabled;

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

CMake + Lua + IUP: dynamic libraries not enabled;

Russell Haley
Hi,

I have a small C/Lua/IUP project that was working on Windows. I am trying to port it over to Linux. I have managed most aspects of the cross-migration but my application is still failing with the following error:

Couldn't load file: error loading module 'iuplua' from file 'iup-toolkit/libiuplua.so':
dynamic libraries not enabled; check your Lua installation

I have definitely built a shared object for Lua: liblua54.so. I "sprinkled" liblua54.so around very liberally in every directory that I thought it might be needed, but that has no effect.

If I run the Lua executable created with that shared object it also gives me the error:

starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug$ ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  iup-toolkit  lfs-1.8.0  lfs.so  liblfs.so  liblua54.so  lua  lua-5.4  Makefile  MyCProject.cbp  share  starfishIUPGui  starfishIUPGui.cbp
starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug$ ./lua
Lua 5.4.0  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> require 'lfs'
error loading module 'lfs' from file './lfs.so':
dynamic libraries not enabled; check your Lua installation
stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
>

Have I missed a define or something? Any hit would be very helpful?

Thanks,
Russ
Reply | Threaded
Open this post in threaded view
|

Re: CMake + Lua + IUP: dynamic libraries not enabled;

Paul K-2
Hi Russ,

> dynamic libraries not enabled; check your Lua installation

You need to have `LUA_USE_DLOPEN` defined (it's `LUA_DL_DLL` on
Windows); using LUA_USE_LINUX should enable that as well.

Paul.

On Tue, Jan 26, 2021 at 3:44 PM Russell Haley <[hidden email]> wrote:

>
> Hi,
>
> I have a small C/Lua/IUP project that was working on Windows. I am trying to port it over to Linux. I have managed most aspects of the cross-migration but my application is still failing with the following error:
>
> Couldn't load file: error loading module 'iuplua' from file 'iup-toolkit/libiuplua.so':
> dynamic libraries not enabled; check your Lua installation
>
> I have definitely built a shared object for Lua: liblua54.so. I "sprinkled" liblua54.so around very liberally in every directory that I thought it might be needed, but that has no effect.
>
> If I run the Lua executable created with that shared object it also gives me the error:
>
> starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug$ ls
> CMakeCache.txt  CMakeFiles  cmake_install.cmake  iup-toolkit  lfs-1.8.0  lfs.so  liblfs.so  liblua54.so  lua  lua-5.4  Makefile  MyCProject.cbp  share  starfishIUPGui  starfishIUPGui.cbp
> starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug$ ./lua
> Lua 5.4.0  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> > require 'lfs'
> error loading module 'lfs' from file './lfs.so':
> dynamic libraries not enabled; check your Lua installation
> stack traceback:
> [C]: in ?
> [C]: in function 'require'
> stdin:1: in main chunk
> [C]: in ?
> >
>
> Have I missed a define or something? Any hit would be very helpful?
>
> Thanks,
> Russ
Reply | Threaded
Open this post in threaded view
|

Re:CMake + Lua + IUP: dynamic libraries not enabled;

suote127
In reply to this post by Russell Haley
Maybe you need to build Lua interpreter again.
According to the log,your Lua interpreter does not support dynamic library.
Maybe you should try to build Lua like
    make posix
This should work,

Suote127
Reply | Threaded
Open this post in threaded view
|

Re: CMake + Lua + IUP: dynamic libraries not enabled;

Russell Haley
In reply to this post by Paul K-2



On Tue, Jan 26, 2021 at 4:12 PM Paul K <[hidden email]> wrote:
Hi Russ,

> dynamic libraries not enabled; check your Lua installation

You need to have `LUA_USE_DLOPEN` defined (it's `LUA_DL_DLL` on
Windows); using LUA_USE_LINUX should enable that as well.

Ah, ha! CMake newb mistake: 

OPTION ( LUA_USE_POSIX "Use POSIX functionality." ON )

is not the same as

ADD_DEFINITIONS (-DLUA_USE_POSIX)

The first one is a CMake variable, the second is a C define. Oops.

Russ

Paul.

On Tue, Jan 26, 2021 at 3:44 PM Russell Haley <[hidden email]> wrote:
>
> Hi,
>
> I have a small C/Lua/IUP project that was working on Windows. I am trying to port it over to Linux. I have managed most aspects of the cross-migration but my application is still failing with the following error:
>
> Couldn't load file: error loading module 'iuplua' from file 'iup-toolkit/libiuplua.so':
> dynamic libraries not enabled; check your Lua installation
>
> I have definitely built a shared object for Lua: liblua54.so. I "sprinkled" liblua54.so around very liberally in every directory that I thought it might be needed, but that has no effect.
>
> If I run the Lua executable created with that shared object it also gives me the error:
>
> starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug$ ls
> CMakeCache.txt  CMakeFiles  cmake_install.cmake  iup-toolkit  lfs-1.8.0  lfs.so  liblfs.so  liblua54.so  lua  lua-5.4  Makefile  MyCProject.cbp  share  starfishIUPGui  starfishIUPGui.cbp
> starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug$ ./lua
> Lua 5.4.0  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> > require 'lfs'
> error loading module 'lfs' from file './lfs.so':
> dynamic libraries not enabled; check your Lua installation
> stack traceback:
> [C]: in ?
> [C]: in function 'require'
> stdin:1: in main chunk
> [C]: in ?
> >
>
> Have I missed a define or something? Any hit would be very helpful?
>
> Thanks,
> Russ
Reply | Threaded
Open this post in threaded view
|

Re: CMake + Lua + IUP: dynamic libraries not enabled;

Russell Haley
Oh, for the love of Pete!

starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug/lua-5.4$ ./lua-debug
Lua 5.4.0  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> require 'lfs'
error loading module 'lfs' from file './lfs.so':
./lfs.so: undefined symbol: lua_newuserdata
stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
>

Any ideas? I would think this should have failed to build if lua_newuserdata was really missing?


On Tue, Jan 26, 2021 at 4:51 PM Russell Haley <[hidden email]> wrote:



On Tue, Jan 26, 2021 at 4:12 PM Paul K <[hidden email]> wrote:
Hi Russ,

> dynamic libraries not enabled; check your Lua installation

You need to have `LUA_USE_DLOPEN` defined (it's `LUA_DL_DLL` on
Windows); using LUA_USE_LINUX should enable that as well.

Ah, ha! CMake newb mistake: 

OPTION ( LUA_USE_POSIX "Use POSIX functionality." ON )

is not the same as

ADD_DEFINITIONS (-DLUA_USE_POSIX)

The first one is a CMake variable, the second is a C define. Oops.

Russ

Paul.

On Tue, Jan 26, 2021 at 3:44 PM Russell Haley <[hidden email]> wrote:
>
> Hi,
>
> I have a small C/Lua/IUP project that was working on Windows. I am trying to port it over to Linux. I have managed most aspects of the cross-migration but my application is still failing with the following error:
>
> Couldn't load file: error loading module 'iuplua' from file 'iup-toolkit/libiuplua.so':
> dynamic libraries not enabled; check your Lua installation
>
> I have definitely built a shared object for Lua: liblua54.so. I "sprinkled" liblua54.so around very liberally in every directory that I thought it might be needed, but that has no effect.
>
> If I run the Lua executable created with that shared object it also gives me the error:
>
> starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug$ ls
> CMakeCache.txt  CMakeFiles  cmake_install.cmake  iup-toolkit  lfs-1.8.0  lfs.so  liblfs.so  liblua54.so  lua  lua-5.4  Makefile  MyCProject.cbp  share  starfishIUPGui  starfishIUPGui.cbp
> starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug$ ./lua
> Lua 5.4.0  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> > require 'lfs'
> error loading module 'lfs' from file './lfs.so':
> dynamic libraries not enabled; check your Lua installation
> stack traceback:
> [C]: in ?
> [C]: in function 'require'
> stdin:1: in main chunk
> [C]: in ?
> >
>
> Have I missed a define or something? Any hit would be very helpful?
>
> Thanks,
> Russ
Reply | Threaded
Open this post in threaded view
|

Re: CMake + Lua + IUP: dynamic libraries not enabled;

Jonathan Goble
On Tue, Jan 26, 2021 at 8:11 PM Russell Haley <[hidden email]> wrote:
Oh, for the love of Pete!

starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug/lua-5.4$ ./lua-debug
Lua 5.4.0  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> require 'lfs'
error loading module 'lfs' from file './lfs.so':
./lfs.so: undefined symbol: lua_newuserdata
stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
>

Any ideas? I would think this should have failed to build if lua_newuserdata was really missing?

Because lfs.so was built for an earlier version of Lua in which lua_newuserdata was a function. In Lua 5.4, it is now provided as a macro due to the introduction of a variable number of user values, and as such, exists only at compile time now.
Reply | Threaded
Open this post in threaded view
|

Re: CMake + Lua + IUP: dynamic libraries not enabled;

Russell Haley


On Tue, Jan 26, 2021 at 8:26 PM Jonathan Goble <[hidden email]> wrote:
On Tue, Jan 26, 2021 at 8:11 PM Russell Haley <[hidden email]> wrote:
Oh, for the love of Pete!

starfish@linux-dev-2:~/starfishIUPGui/cmake-build-debug/lua-5.4$ ./lua-debug
Lua 5.4.0  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> require 'lfs'
error loading module 'lfs' from file './lfs.so':
./lfs.so: undefined symbol: lua_newuserdata
stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
>

Any ideas? I would think this should have failed to build if lua_newuserdata was really missing?

Because lfs.so was built for an earlier version of Lua in which lua_newuserdata was a function. In Lua 5.4, it is now provided as a macro due to the introduction of a variable number of user values, and as such, exists only at compile time now.

Thanks Jonathan. I deleted my system installation of 5.3.6 and suddenly the build fails. ha ha. This error is even more fun than building modules with two vms. I was considering putting that on my resume: "Consistently builds lua modules with at least two vms." I wonder if *anyone* would ever pick up on that?

Thanks Again!
Russ